|
1
|
|
|
<?php |
|
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 2020 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace OCA\Music\Db; |
|
14
|
|
|
|
|
15
|
|
|
use OCP\IDBConnection; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
class GenreMapper extends BaseMapper { |
|
18
|
|
|
public function __construct(IDBConnection $db) { |
|
19
|
|
|
parent::__construct($db, 'music_genres', '\OCA\Music\Db\Genre', 'name'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @see \OCA\Music\Db\BaseMapper::findUniqueEntity() |
|
24
|
|
|
* @param Genre $genre |
|
25
|
|
|
* @return Genre |
|
26
|
|
|
*/ |
|
27
|
|
|
protected function findUniqueEntity($genre) { |
|
28
|
|
|
$sql = $this->selectGenres('`*PREFIX*music_genres`.`user_id` = ? AND `lower_name` = ?'); |
|
29
|
|
|
return $this->findEntity($sql, [$genre->getUserId(), $genre->getLowerName()]); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Create SQL query which selects genres excluding any empty genres (having no tracks) |
|
34
|
|
|
* @see \OCA\Music\Db\BaseMapper::selectEntities |
|
35
|
|
|
* @param string $condition |
|
36
|
|
|
* @param string|null $extension |
|
37
|
|
|
* @return string SQL query |
|
38
|
|
|
*/ |
|
39
|
|
|
protected function selectEntities($condition, $extension=null) { |
|
40
|
|
|
return $this->selectGenres($condition, 'HAVING COUNT(`track`.`id`) > 0 ' . $extension); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Create SQL query to select genres. Unlike the function selectEntities used by the |
|
45
|
|
|
* base class BaseMapper, this function returns also the genres with no tracks at all. |
|
46
|
|
|
* @param string $condition |
|
47
|
|
|
* @param string|null $extension |
|
48
|
|
|
* @return string SQL query |
|
49
|
|
|
*/ |
|
50
|
|
|
private function selectGenres($condition, $extension=null) { |
|
51
|
|
|
return "SELECT |
|
52
|
|
|
`*PREFIX*music_genres`.`id`, |
|
53
|
|
|
`*PREFIX*music_genres`.`name`, |
|
54
|
|
|
`*PREFIX*music_genres`.`lower_name`, |
|
55
|
|
|
COUNT(`track`.`id`) AS `trackCount`, |
|
56
|
|
|
COUNT(DISTINCT(`track`.`album_id`)) AS `albumCount`, |
|
57
|
|
|
COUNT(DISTINCT(`track`.`artist_id`)) AS `artistCount` |
|
58
|
|
|
FROM `*PREFIX*music_genres` |
|
59
|
|
|
LEFT JOIN `*PREFIX*music_tracks` `track` |
|
60
|
|
|
ON `track`.`genre_id` = `*PREFIX*music_genres`.`id` |
|
61
|
|
|
WHERE $condition |
|
62
|
|
|
GROUP BY `*PREFIX*music_genres`.`id`, `*PREFIX*music_genres`.`name`, `*PREFIX*music_genres`.`lower_name` |
|
63
|
|
|
$extension"; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths