1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ownCloud - Music app |
5
|
|
|
* |
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
7
|
|
|
* later. See the COPYING file. |
8
|
|
|
* |
9
|
|
|
* @author Pauli Järvinen <[email protected]> |
10
|
|
|
* @copyright Pauli Järvinen 2021 - 2023 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace OCA\Music\Db; |
14
|
|
|
|
15
|
|
|
use OCP\IDBConnection; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Type hint a base class methdo to help Scrutinizer |
19
|
|
|
* @method PodcastChannel insert(PodcastChannel $channel) |
20
|
|
|
* @phpstan-extends BaseMapper<PodcastChannel> |
21
|
|
|
*/ |
22
|
|
|
class PodcastChannelMapper extends BaseMapper { |
23
|
|
|
public function __construct(IDBConnection $db) { |
24
|
|
|
parent::__construct($db, 'music_podcast_channels', PodcastChannel::class, 'title'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return int[] |
29
|
|
|
*/ |
30
|
|
|
public function findAllIdsWithNoUpdateSince(string $userId, \DateTime $timeLimit) : array { |
31
|
|
|
$sql = "SELECT `id` FROM `{$this->getTableName()}` WHERE `user_id` = ? AND `update_checked` < ?"; |
|
|
|
|
32
|
|
|
$result = $this->execute($sql, [$userId, $timeLimit->format(BaseMapper::SQL_DATE_FORMAT)]); |
|
|
|
|
33
|
|
|
|
34
|
|
|
return \array_map('intval', $result->fetchAll(\PDO::FETCH_COLUMN)); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Overridden from the base implementation to provide support for table-specific rules |
39
|
|
|
* |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
* @see BaseMapper::advFormatSqlCondition() |
42
|
|
|
*/ |
43
|
|
|
protected function advFormatSqlCondition(string $rule, string $sqlOp) : string { |
44
|
|
|
switch ($rule) { |
45
|
|
|
case 'podcast_episode': return "`*PREFIX*music_podcast_channels`.`id` IN (SELECT `channel_id` FROM `*PREFIX*music_podcast_episodes` `e` WHERE LOWER(`e`.`title`) $sqlOp LOWER(?))"; |
46
|
|
|
case 'time': return "`*PREFIX*music_podcast_channels`.`id` IN (SELECT * FROM (SELECT `channel_id` FROM `*PREFIX*music_podcast_episodes` GROUP BY `channel_id` HAVING SUM(`duration`) $sqlOp ?) mysqlhack)"; |
47
|
|
|
case 'pubdate': return "`published` $sqlOp ?"; |
48
|
|
|
default: return parent::advFormatSqlCondition($rule, $sqlOp); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @see \OCA\Music\Db\BaseMapper::findUniqueEntity() |
54
|
|
|
* @param PodcastChannel $channel |
55
|
|
|
* @return PodcastChannel |
56
|
|
|
*/ |
57
|
|
|
protected function findUniqueEntity(Entity $channel) : Entity { |
58
|
|
|
$sql = $this->selectUserEntities("`rss_hash` = ?"); |
59
|
|
|
return $this->findEntity($sql, [$channel->getUserId(), $channel->getRssHash()]); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.