clusters: make fileid filter generic
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/767/head
parent
268268da40
commit
db5030c18b
|
@ -87,12 +87,8 @@ class AlbumsBackend extends Backend
|
|||
$this->tq->allowEmptyRoot();
|
||||
}
|
||||
|
||||
public function getClusters(): array
|
||||
public function getClusters(int $fileid = 0): array
|
||||
{
|
||||
/** @var \OCP\IRequest $request */
|
||||
$request = \OC::$server->get(\OCP\IRequest::class);
|
||||
$fileid = (int) $request->getParam('fileid', -1);
|
||||
|
||||
// Run actual queries
|
||||
$list = [];
|
||||
|
||||
|
|
|
@ -60,8 +60,10 @@ abstract class Backend
|
|||
|
||||
/**
|
||||
* Get the cluster list for the current user.
|
||||
*
|
||||
* @param int $fileid Filter clusters by file ID (optional)
|
||||
*/
|
||||
abstract public function getClusters(): array;
|
||||
abstract public function getClusters(int $fileid = 0): array;
|
||||
|
||||
/**
|
||||
* Get a cluster ID for the given cluster.
|
||||
|
|
|
@ -123,8 +123,12 @@ class FaceRecognitionBackend extends Backend
|
|||
unset($row['face_x'], $row['face_y'], $row['face_w'], $row['face_h'], $row['image_height'], $row['image_width']);
|
||||
}
|
||||
|
||||
public function getClusters(): array
|
||||
public function getClusters(int $fileid = 0): array
|
||||
{
|
||||
if ($fileid) {
|
||||
throw new \Exception('FaceRecognitionBackend: fileid filter not implemented');
|
||||
}
|
||||
|
||||
$faces = array_merge(
|
||||
$this->getFaceRecognitionPersons(),
|
||||
$this->getFaceRecognitionClusters()
|
||||
|
|
|
@ -63,8 +63,12 @@ class PlacesBackend extends Backend
|
|||
));
|
||||
}
|
||||
|
||||
public function getClusters(): array
|
||||
public function getClusters(int $fileid = 0): array
|
||||
{
|
||||
if ($fileid) {
|
||||
throw new \Exception('PlacesBackend: fileid filter not implemented');
|
||||
}
|
||||
|
||||
$inside = (int) $this->request->getParam('inside', 0);
|
||||
$marked = (int) $this->request->getParam('mark', 1);
|
||||
|
||||
|
|
|
@ -129,12 +129,8 @@ class RecognizeBackend extends Backend
|
|||
unset($row['face_w'], $row['face_h'], $row['face_x'], $row['face_y']);
|
||||
}
|
||||
|
||||
public function getClusters(): array
|
||||
public function getClusters(int $fileid = 0): array
|
||||
{
|
||||
/** @var \OCP\IRequest $request */
|
||||
$request = \OC::$server->get(\OCP\IRequest::class);
|
||||
$fileid = (int) $request->getParam('fileid', -1);
|
||||
|
||||
$query = $this->tq->getBuilder();
|
||||
|
||||
// SELECT all face clusters
|
||||
|
|
|
@ -67,8 +67,12 @@ class TagsBackend extends Backend
|
|||
));
|
||||
}
|
||||
|
||||
public function getClusters(): array
|
||||
public function getClusters(int $fileid = 0): array
|
||||
{
|
||||
if ($fileid) {
|
||||
throw new \Exception('TagsBackend: fileid filter not implemented');
|
||||
}
|
||||
|
||||
$query = $this->tq->getBuilder();
|
||||
|
||||
// SELECT visible tag name and count of photos
|
||||
|
|
|
@ -40,12 +40,12 @@ class ClustersController extends GenericApiController
|
|||
*
|
||||
* Get list of clusters
|
||||
*/
|
||||
public function list(string $backend): Http\Response
|
||||
public function list(string $backend, int $fileid = 0): Http\Response
|
||||
{
|
||||
return Util::guardEx(function () use ($backend) {
|
||||
return Util::guardEx(function () use ($backend, $fileid) {
|
||||
$this->init($backend);
|
||||
|
||||
$list = $this->backend->getClusters();
|
||||
$list = $this->backend->getClusters($fileid);
|
||||
|
||||
// Set cluster_id and cluster_type for each cluster
|
||||
foreach ($list as &$cluster) {
|
||||
|
|
|
@ -22,7 +22,7 @@ class AlbumsQuery
|
|||
* @param bool $shared Whether to get shared albums
|
||||
* @param int $fileid File to filter by
|
||||
*/
|
||||
public function getList(string $uid, bool $shared = false, int $fileid = -1)
|
||||
public function getList(string $uid, bool $shared = false, int $fileid = 0)
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
|
||||
|
@ -68,7 +68,7 @@ class AlbumsQuery
|
|||
$query->addOrderBy('pa.album_id', 'DESC'); // tie-breaker
|
||||
|
||||
// WHERE these albums contain fileid if specified
|
||||
if ($fileid > 0) {
|
||||
if ($fileid) {
|
||||
$fSq = $this->connection->getQueryBuilder()
|
||||
->select('paf.file_id')
|
||||
->from('photos_albums_files', 'paf')
|
||||
|
|
Loading…
Reference in New Issue