2019-04-08 16:52:03 +00:00
|
|
|
<?php
|
2022-04-15 11:34:01 +00:00
|
|
|
|
2019-04-08 16:52:03 +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
|
2019-04-08 16:52:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Social\Db;
|
|
|
|
|
|
|
|
use OCA\Social\Model\StreamAction;
|
2023-05-25 20:45:28 +00:00
|
|
|
use OCA\Social\Tools\Traits\TArrayTools;
|
2019-04-08 16:52:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class StreamActionsRequestBuilder
|
|
|
|
*
|
|
|
|
* @package OCA\Social\Db
|
|
|
|
*/
|
|
|
|
class StreamActionsRequestBuilder extends CoreRequestBuilder {
|
|
|
|
use TArrayTools;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base of the Sql Insert request
|
|
|
|
*
|
2022-12-03 16:55:34 +00:00
|
|
|
* @return SocialQueryBuilder
|
2019-04-08 16:52:03 +00:00
|
|
|
*/
|
2022-11-22 23:16:36 +00:00
|
|
|
protected function getStreamActionInsertSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2019-04-08 16:52:03 +00:00
|
|
|
$qb->insert(self::TABLE_STREAM_ACTIONS);
|
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base of the Sql Update request
|
|
|
|
*
|
2022-12-03 16:55:34 +00:00
|
|
|
* @return SocialQueryBuilder
|
2019-04-08 16:52:03 +00:00
|
|
|
*/
|
2022-11-22 23:16:36 +00:00
|
|
|
protected function getStreamActionUpdateSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2019-04-08 16:52:03 +00:00
|
|
|
$qb->update(self::TABLE_STREAM_ACTIONS);
|
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base of the Sql Select request for Shares
|
|
|
|
*
|
2020-06-25 02:48:36 +00:00
|
|
|
* @return SocialQueryBuilder
|
2019-04-08 16:52:03 +00:00
|
|
|
*/
|
2020-06-25 02:48:36 +00:00
|
|
|
protected function getStreamActionSelectSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2019-04-08 16:52:03 +00:00
|
|
|
|
|
|
|
/** @noinspection PhpMethodParametersCountMismatchInspection */
|
2023-06-13 22:31:37 +00:00
|
|
|
$qb->select(
|
|
|
|
'sa.id', 'sa.actor_id', 'sa.stream_id',
|
|
|
|
'sa.boosted', 'sa.liked', 'sa.replied'
|
|
|
|
)
|
2019-04-08 16:52:03 +00:00
|
|
|
->from(self::TABLE_STREAM_ACTIONS, 'sa');
|
|
|
|
|
|
|
|
$this->defaultSelectAlias = 'sa';
|
2020-06-25 02:48:36 +00:00
|
|
|
$qb->setDefaultSelectAlias('sa');
|
2019-04-08 16:52:03 +00:00
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base of the Sql Delete request
|
|
|
|
*
|
2022-12-03 16:55:34 +00:00
|
|
|
* @return SocialQueryBuilder
|
2019-04-08 16:52:03 +00:00
|
|
|
*/
|
2022-11-22 23:16:36 +00:00
|
|
|
protected function getStreamActionDeleteSql(): SocialQueryBuilder {
|
|
|
|
$qb = $this->getQueryBuilder();
|
2019-04-08 16:52:03 +00:00
|
|
|
$qb->delete(self::TABLE_STREAM_ACTIONS);
|
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return StreamAction
|
|
|
|
*/
|
2020-06-18 19:40:57 +00:00
|
|
|
public function parseStreamActionsSelectSql($data): StreamAction {
|
2019-04-08 16:52:03 +00:00
|
|
|
$action = new StreamAction();
|
|
|
|
$action->importFromDatabase($data);
|
|
|
|
|
|
|
|
return $action;
|
|
|
|
}
|
|
|
|
}
|