Loading Core/Hashtags/User/Manager.php +20 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class Manager public function __construct($repository = null, $trendingRepository = null, $cacher = null, $config = null) { $this->repository = $repository ?: new Repository; // $this->trendingRepository = $trendingRepository ?: new TrendingRepository; $this->trendingRepository = $trendingRepository ?: new TrendingRepository; $this->cacher = $cacher ?: Di::_()->get('Cache'); $this->config = $config ?: Di::_()->get('Config'); } Loading Loading @@ -83,6 +83,25 @@ class Manager } } // Trending hashtags $trending = []; if ($opts['trending']) { $cached = $this->cacher->get($this->getCacheKey('trending')); if ($cached !== false) { $trending = json_decode($cached, true); } else { $results = $this->trendingRepository->getList($opts); if ($results) { $trending = $results; $this->cacher->set($this->getCacheKey('trending'), json_encode($trending), 60 * 15); // 15 minutes } } } // Default hashtags if ($opts['defaults']) { Loading Core/Hashtags/User/Repository.php +23 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class Repository public function __construct($db = null, $legacyRepository = null, $config = null) { $this->db = $db ?: Di::_()->get('Database\Cassandra\Cql'); // $this->legacyRepository = $legacyRepository ?: new LegacyRepository(); $this->legacyRepository = $legacyRepository ?: new LegacyRepository(); $this->config = $config ?: Di::_()->get('Config'); } Loading @@ -35,6 +35,20 @@ class Repository */ public function getAll($opts = []) { // Legacy fallback if ($this->config->get('user_hashtags_legacy_read')) { $rows = $this->legacyRepository->getAll($opts); $response = new Response(); foreach ($rows as $row) { $response[] = (new HashtagEntity()) ->setGuid($opts['user_guid']) ->setHashtag($row['hashtag']); } return $response; } $opts = array_merge([ 'user_guid' => null ], $opts); Loading Loading @@ -98,6 +112,10 @@ class Repository } } if ($this->config->get('user_hashtags_migration')) { $this->legacyRepository->add($hashtags); } return true; } Loading Loading @@ -130,6 +148,10 @@ class Repository return false; } if ($this->config->get('user_hashtags_migration')) { $this->legacyRepository->remove($userGuid, $hashtagValues); } return true; } Loading Loading
Core/Hashtags/User/Manager.php +20 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class Manager public function __construct($repository = null, $trendingRepository = null, $cacher = null, $config = null) { $this->repository = $repository ?: new Repository; // $this->trendingRepository = $trendingRepository ?: new TrendingRepository; $this->trendingRepository = $trendingRepository ?: new TrendingRepository; $this->cacher = $cacher ?: Di::_()->get('Cache'); $this->config = $config ?: Di::_()->get('Config'); } Loading Loading @@ -83,6 +83,25 @@ class Manager } } // Trending hashtags $trending = []; if ($opts['trending']) { $cached = $this->cacher->get($this->getCacheKey('trending')); if ($cached !== false) { $trending = json_decode($cached, true); } else { $results = $this->trendingRepository->getList($opts); if ($results) { $trending = $results; $this->cacher->set($this->getCacheKey('trending'), json_encode($trending), 60 * 15); // 15 minutes } } } // Default hashtags if ($opts['defaults']) { Loading
Core/Hashtags/User/Repository.php +23 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class Repository public function __construct($db = null, $legacyRepository = null, $config = null) { $this->db = $db ?: Di::_()->get('Database\Cassandra\Cql'); // $this->legacyRepository = $legacyRepository ?: new LegacyRepository(); $this->legacyRepository = $legacyRepository ?: new LegacyRepository(); $this->config = $config ?: Di::_()->get('Config'); } Loading @@ -35,6 +35,20 @@ class Repository */ public function getAll($opts = []) { // Legacy fallback if ($this->config->get('user_hashtags_legacy_read')) { $rows = $this->legacyRepository->getAll($opts); $response = new Response(); foreach ($rows as $row) { $response[] = (new HashtagEntity()) ->setGuid($opts['user_guid']) ->setHashtag($row['hashtag']); } return $response; } $opts = array_merge([ 'user_guid' => null ], $opts); Loading Loading @@ -98,6 +112,10 @@ class Repository } } if ($this->config->get('user_hashtags_migration')) { $this->legacyRepository->add($hashtags); } return true; } Loading Loading @@ -130,6 +148,10 @@ class Repository return false; } if ($this->config->get('user_hashtags_migration')) { $this->legacyRepository->remove($userGuid, $hashtagValues); } return true; } Loading