2018-11-23 20:41:46 +00:00
|
|
|
<?php
|
2022-04-15 11:34:01 +00:00
|
|
|
|
2018-11-23 20:41:46 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
2024-09-08 13:46:22 +00:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-11-23 20:41:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Social\Db;
|
|
|
|
|
2018-12-13 09:40:27 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Document;
|
2023-05-25 20:45:28 +00:00
|
|
|
use OCA\Social\Tools\Traits\TArrayTools;
|
2018-11-23 20:41:46 +00:00
|
|
|
|
|
|
|
class CacheDocumentsRequestBuilder extends CoreRequestBuilder {
|
|
|
|
use TArrayTools;
|
|
|
|
|
2022-11-22 23:16:36 +00:00
|
|
|
protected function getCacheDocumentsInsertSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2018-11-23 20:41:46 +00:00
|
|
|
$qb->insert(self::TABLE_CACHE_DOCUMENTS);
|
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base of the Sql Update request
|
|
|
|
*/
|
2022-11-22 23:16:36 +00:00
|
|
|
protected function getCacheDocumentsUpdateSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2018-11-23 20:41:46 +00:00
|
|
|
$qb->update(self::TABLE_CACHE_DOCUMENTS);
|
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base of the Sql Select request for Shares
|
|
|
|
*/
|
2020-06-25 02:48:36 +00:00
|
|
|
protected function getCacheDocumentsSelectSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2018-11-23 20:41:46 +00:00
|
|
|
|
|
|
|
$qb->select(
|
2023-02-23 12:06:39 +00:00
|
|
|
'cd.nid', 'cd.id', 'cd.type', 'cd.parent_id', 'cd.account',
|
|
|
|
'cd.media_type', 'cd.mime_type', 'cd.url', 'cd.local_copy', 'cd.public',
|
2023-03-07 15:30:12 +00:00
|
|
|
'cd.error', 'cd.creation', 'cd.caching', 'cd.resized_copy', 'cd.meta',
|
|
|
|
'cd.blurhash', 'cd.description'
|
2018-11-23 20:41:46 +00:00
|
|
|
)
|
2024-10-28 12:53:06 +00:00
|
|
|
->from(self::TABLE_CACHE_DOCUMENTS, 'cd');
|
2018-11-23 20:41:46 +00:00
|
|
|
|
|
|
|
$this->defaultSelectAlias = 'cd';
|
2020-06-25 02:48:36 +00:00
|
|
|
$qb->setDefaultSelectAlias('cd');
|
2018-11-23 20:41:46 +00:00
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base of the Sql Delete request
|
|
|
|
*/
|
2022-11-22 23:16:36 +00:00
|
|
|
protected function getCacheDocumentsDeleteSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2018-11-23 20:41:46 +00:00
|
|
|
$qb->delete(self::TABLE_CACHE_DOCUMENTS);
|
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
2020-06-18 19:40:57 +00:00
|
|
|
public function parseCacheDocumentsSelectSql(array $data): Document {
|
2018-11-23 20:41:46 +00:00
|
|
|
$document = new Document();
|
|
|
|
$document->importFromDatabase($data);
|
|
|
|
|
|
|
|
return $document;
|
|
|
|
}
|
|
|
|
}
|