Commit da07df74 authored by Mark Harding's avatar Mark Harding

Revert "(chore): no need to still load legacy repositories"

This reverts commit ba96c0f9.
parent 87d80121
No related merge requests found
Pipeline #68890418 passed with stages
in 6 minutes and 47 seconds
......@@ -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');
}
......@@ -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']) {
......
......@@ -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');
}
......@@ -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);
......@@ -98,6 +112,10 @@ class Repository
}
}
if ($this->config->get('user_hashtags_migration')) {
$this->legacyRepository->add($hashtags);
}
return true;
}
......@@ -130,6 +148,10 @@ class Repository
return false;
}
if ($this->config->get('user_hashtags_migration')) {
$this->legacyRepository->remove($userGuid, $hashtagValues);
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment