|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OCA\FaceRecognition\Settings; |
|
4
|
|
|
|
|
5
|
|
|
use OCA\Viewer\Event\LoadViewer; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use OCP\EventDispatcher\IEventDispatcher; |
|
8
|
|
|
use OCP\AppFramework\Http\TemplateResponse; |
|
9
|
|
|
use OCP\AppFramework\Services\IInitialState; |
|
10
|
|
|
use OCP\Settings\ISettings; |
|
11
|
|
|
|
|
12
|
|
|
use OCA\FaceRecognition\Db\Person; |
|
13
|
|
|
use OCA\FaceRecognition\Db\PersonMapper; |
|
14
|
|
|
|
|
15
|
|
|
use OCA\FaceRecognition\Service\SettingsService; |
|
16
|
|
|
|
|
17
|
|
|
class Personal implements ISettings { |
|
18
|
|
|
|
|
19
|
|
|
/** @var IEventDispatcher */ |
|
20
|
|
|
private $eventDispatcher; |
|
21
|
|
|
|
|
22
|
|
|
/** @var \OCP\AppFramework\Services\IInitialState **/ |
|
23
|
|
|
protected IInitialState $initialState; |
|
24
|
|
|
|
|
25
|
|
|
/** @var PersonMapper */ |
|
26
|
|
|
protected $personMapper; |
|
27
|
|
|
|
|
28
|
|
|
/** @var SettingsService */ |
|
29
|
|
|
protected $settingsService; |
|
30
|
|
|
|
|
31
|
|
|
protected ?string $userId; |
|
32
|
|
|
|
|
33
|
|
|
public function __construct(IEventDispatcher $eventDispatcher, |
|
34
|
|
|
IInitialState $initialState, |
|
35
|
|
|
PersonMapper $personmapper, |
|
36
|
|
|
SettingsService $settingsService, |
|
37
|
|
|
string $userId) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->eventDispatcher = $eventDispatcher; |
|
40
|
|
|
$this->initialState = $initialState; |
|
41
|
|
|
$this->personMapper = $personmapper; |
|
42
|
|
|
$this->settingsService = $settingsService; |
|
43
|
|
|
$this->userId = $userId; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getPriority() |
|
47
|
|
|
{ |
|
48
|
|
|
return 20; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getSection() |
|
52
|
|
|
{ |
|
53
|
|
|
return 'facerecognition'; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getSectionID(): string |
|
57
|
|
|
{ |
|
58
|
|
|
return 'facerecognition'; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getForm() |
|
62
|
|
|
{ |
|
63
|
|
|
$userEnabled = $this->settingsService->getUserEnabled($this->userId); |
|
64
|
|
|
$unamedCount = 0; |
|
65
|
|
|
$hiddenCount = 0; |
|
66
|
|
|
|
|
67
|
|
|
if ($userEnabled) { |
|
68
|
|
|
$modelId = $this->settingsService->getCurrentFaceModel(); |
|
69
|
|
|
$minClusterSize = $this->settingsService->getMinimumFacesInCluster(); |
|
70
|
|
|
|
|
71
|
|
|
$clusters = $this->personMapper->findUnassigned($this->userId, $modelId); |
|
|
|
|
|
|
72
|
|
|
foreach ($clusters as $cluster) { |
|
73
|
|
|
$clusterSize = $this->personMapper->countClusterFaces($cluster->getId()); |
|
74
|
|
|
if ($clusterSize >= $minClusterSize) |
|
75
|
|
|
$unamedCount++; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$clusters = $this->personMapper->findIgnored($this->userId, $modelId); |
|
|
|
|
|
|
79
|
|
|
foreach ($clusters as $cluster) { |
|
80
|
|
|
$clusterSize = $this->personMapper->countClusterFaces($cluster->getId()); |
|
81
|
|
|
if ($clusterSize >= $minClusterSize) |
|
82
|
|
|
$hiddenCount++; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
$this->initialState->provideInitialState('user-enabled', $userEnabled); |
|
87
|
|
|
$this->initialState->provideInitialState('has-unamed', $unamedCount > 0); |
|
88
|
|
|
$this->initialState->provideInitialState('has-hidden', $hiddenCount > 0); |
|
89
|
|
|
|
|
90
|
|
|
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer()); |
|
|
|
|
|
|
91
|
|
|
return new TemplateResponse('facerecognition', 'settings/personal'); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function getPanel(): TemplateResponse |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->getForm(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
} |
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