use id_prim on icon_id

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/1662/head
Maxence Lange 2023-03-15 14:25:49 -01:00
rodzic 3fc14ced4f
commit dd0ef70b74
4 zmienionych plików z 14 dodań i 11 usunięć

Wyświetl plik

@ -38,6 +38,7 @@ use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\DocumentService;
use OCA\Social\Service\HashtagService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class CacheRefresh extends Base {
@ -61,7 +62,8 @@ class CacheRefresh extends Base {
protected function configure() {
parent::configure();
$this->setName('social:cache:refresh')
->setDescription('Update the cache');
->setDescription('Update the cache')
->addOption('force', 'f', InputOption::VALUE_NONE, 'enforce update of cached account');
}
/**
@ -80,7 +82,7 @@ class CacheRefresh extends Base {
$result = $this->cacheActorService->missingCacheRemoteActors();
$output->writeLn($result . ' remote accounts created');
$result = $this->cacheActorService->manageCacheRemoteActors();
$result = $this->cacheActorService->manageCacheRemoteActors($input->getOption('force'));
$output->writeLn($result . ' remote accounts updated');
$result = $this->documentService->manageCacheDocuments();

Wyświetl plik

@ -91,7 +91,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
$iconId = $actor->getIconId();
}
$qb->setValue('icon_id', $qb->createNamedParameter($iconId));
$qb->setValue('icon_id', $qb->createNamedParameter($qb->prim($iconId)));
$qb->generatePrimaryKey($actor->getId());
try {
@ -143,9 +143,8 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
$iconId = $actor->getIconId();
}
$qb->set('icon_id', $qb->createNamedParameter($iconId));
$this->limitToIdString($qb, $actor->getId());
$qb->set('icon_id', $qb->createNamedParameter($qb->prim($iconId)));
$qb->limitToIdString($actor->getId());
return $qb->executeStatement();
}
@ -226,10 +225,12 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
* @return Person[]
* @throws Exception
*/
public function getRemoteActorsToUpdate(): array {
public function getRemoteActorsToUpdate(bool $force = false): array {
$qb = $this->getCacheActorsSelectSql();
$this->limitToLocal($qb, false);
$this->limitToCreation($qb, self::CACHE_TTL);
if (!$force) {
$this->limitToCreation($qb, self::CACHE_TTL);
}
return $this->getCacheActorsFromRequest($qb);
}

Wyświetl plik

@ -185,7 +185,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
->selectAlias('cd.creation', 'cachedocument_creation')
->leftJoin(
$this->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'cd',
$expr->eq($func->lower($pf . '.' . $fieldDocumentId), $func->lower('cd.id'))
$expr->eq($pf . '.' . $fieldDocumentId, 'cd.id_prim')
);
}

Wyświetl plik

@ -291,8 +291,8 @@ class CacheActorService {
* @return int
* @throws Exception
*/
public function manageCacheRemoteActors(): int {
$update = $this->cacheActorsRequest->getRemoteActorsToUpdate();
public function manageCacheRemoteActors(bool $force = false): int {
$update = $this->cacheActorsRequest->getRemoteActorsToUpdate($force);
foreach ($update as $item) {
try {