1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2017, 2018, 2020 Matias De lellis <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @author Matias De lellis <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @license GNU AGPL version 3 or any later version |
9
|
|
|
* |
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
13
|
|
|
* License, or (at your option) any later version. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU Affero General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace OCA\FaceRecognition\Search; |
26
|
|
|
|
27
|
|
|
use OCA\FaceRecognition\AppInfo\Application; |
28
|
|
|
|
29
|
|
|
use OCA\FaceRecognition\Db\ImageMapper; |
30
|
|
|
|
31
|
|
|
use OCA\FaceRecognition\Service\SettingsService; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Provide search results from the 'facerecognition' app |
35
|
|
|
*/ |
36
|
|
|
class Provider extends \OCP\Search\PagedProvider { |
37
|
|
|
|
38
|
|
|
/** @var ImageMapper Image mapper */ |
39
|
|
|
private $imageMapper; |
40
|
|
|
|
41
|
|
|
/** @var SettingsService Settings service */ |
42
|
|
|
private $settingsService; |
43
|
|
|
|
44
|
|
|
public function __construct() { |
45
|
|
|
$app = new Application(); |
46
|
|
|
$container = $app->getContainer(); |
47
|
|
|
|
48
|
|
|
$this->imageMapper = $container->query(\OCA\FaceRecognition\Db\ImageMapper::class); |
49
|
|
|
$this->settingsService = $container->query(\OCA\FaceRecognition\Service\SettingsService::class); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $query |
54
|
|
|
* @param int|null $page |
55
|
|
|
* @param int|null $size |
56
|
|
|
* @return \OCP\Search\Result[] |
57
|
|
|
*/ |
58
|
|
|
function searchPaged($query, $page, $size) { |
59
|
|
|
|
60
|
|
|
$userId = \OC::$server->getUserSession()->getUser()->getUID(); |
61
|
|
|
$ownerView = new \OC\Files\View('/'. $userId . '/files'); |
|
|
|
|
62
|
|
|
|
63
|
|
|
$model = $this->settingsService->getCurrentFaceModel(); |
64
|
|
|
|
65
|
|
|
$searchresults = array(); |
66
|
|
|
|
67
|
|
|
$results = $this->imageMapper->findFromPersonLike($userId, $model, $query, ($page - 1) * $size, $size); |
68
|
|
|
foreach($results as $result) { |
69
|
|
|
$fileId = $result->getFile(); |
70
|
|
|
try { |
71
|
|
|
$path = $ownerView->getPath($fileId); |
72
|
|
|
} catch (\OCP\Files\NotFoundException $e) { |
73
|
|
|
continue; |
74
|
|
|
} |
75
|
|
|
$fileInfo = $ownerView->getFileInfo($path); |
76
|
|
|
$searchresults[] = new \OC\Search\Result\Image($fileInfo); |
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return $searchresults; |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
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