refactor: use selectAlias
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/783/head
parent
4e3ed6fc49
commit
9fe1c02076
|
@ -94,14 +94,13 @@ class FaceRecognitionBackend extends Backend
|
|||
|
||||
// Add face rect
|
||||
if (!$aggregate && $this->request->getParam('facerect')) {
|
||||
$query->addSelect(
|
||||
'frf.x AS face_x',
|
||||
'frf.y AS face_y',
|
||||
'frf.width AS face_width',
|
||||
'frf.height AS face_height',
|
||||
'm.w AS image_width',
|
||||
'm.h AS image_height',
|
||||
);
|
||||
$query->selectAlias('frf.x', 'face_x')
|
||||
->selectAlias('frf.y', 'face_y')
|
||||
->selectAlias('frf.width', 'face_width')
|
||||
->selectAlias('frf.height', 'face_height')
|
||||
->selectAlias('m.w', 'image_width')
|
||||
->selectAlias('m.h', 'image_height')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,16 +78,15 @@ class RecognizeBackend extends Backend
|
|||
|
||||
if (!$aggregate) {
|
||||
// Multiple detections for the same image
|
||||
$query->addSelect('rfd.id AS faceid');
|
||||
$query->selectAlias('rfd.id', 'faceid');
|
||||
|
||||
// Face Rect
|
||||
if ($this->request->getParam('facerect')) {
|
||||
$query->addSelect(
|
||||
'rfd.width AS face_w',
|
||||
'rfd.height AS face_h',
|
||||
'rfd.x AS face_x',
|
||||
'rfd.y AS face_y',
|
||||
);
|
||||
$query->selectAlias('rfd.width', 'face_w')
|
||||
->selectAlias('rfd.height', 'face_h')
|
||||
->selectAlias('rfd.x', 'face_x')
|
||||
->selectAlias('rfd.y', 'face_y')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,19 +40,18 @@ trait TimelineQueryMap
|
|||
$query = $this->connection->getQueryBuilder();
|
||||
|
||||
// Get the average location of each cluster
|
||||
$id = $query->createFunction('MAX(c.id) as id');
|
||||
$ct = $query->createFunction('COUNT(m.fileid) AS count');
|
||||
$lat = $query->createFunction('AVG(c.lat) AS lat');
|
||||
$lon = $query->createFunction('AVG(c.lon) AS lon');
|
||||
|
||||
$query->select($id, $ct, $lat, $lon)
|
||||
$query->selectAlias($query->createFunction('MAX(c.id)'), 'id')
|
||||
->selectAlias($query->createFunction('COUNT(m.fileid)'), 'count')
|
||||
->selectAlias($query->createFunction('AVG(c.lat)'), 'lat')
|
||||
->selectAlias($query->createFunction('AVG(c.lon)'), 'lon')
|
||||
->from('memories_mapclusters', 'c')
|
||||
;
|
||||
|
||||
// Coarse grouping
|
||||
$gridParam = $query->createNamedParameter($gridLen, IQueryBuilder::PARAM_STR);
|
||||
$query->addGroupBy($query->createFunction("FLOOR(c.lat / {$gridParam})"));
|
||||
$query->addGroupBy($query->createFunction("FLOOR(c.lon / {$gridParam})"));
|
||||
$query->addGroupBy($query->createFunction("FLOOR(c.lat / {$gridParam})"))
|
||||
->addGroupBy($query->createFunction("FLOOR(c.lon / {$gridParam})"))
|
||||
;
|
||||
|
||||
// JOIN with memories for files from the current user
|
||||
$query->innerJoin('c', 'memories', 'm', $query->expr()->eq('c.id', 'm.mapcluster'));
|
||||
|
@ -90,10 +89,13 @@ trait TimelineQueryMap
|
|||
$query = $this->connection->getQueryBuilder();
|
||||
|
||||
// SELECT all photos with this tag
|
||||
$fileid = $query->createFunction('MAX(m.fileid) AS fileid');
|
||||
$query->select($fileid)->from('memories', 'm')->where(
|
||||
$query->expr()->in('m.mapcluster', $query->createNamedParameter($clusterIds, IQueryBuilder::PARAM_INT_ARRAY))
|
||||
);
|
||||
$query->selectAlias($query->createFunction('MAX(m.fileid)'), 'fileid')
|
||||
->from('memories', 'm')
|
||||
->where($query->expr()->in('m.mapcluster', $query->createNamedParameter(
|
||||
$clusterIds,
|
||||
IQueryBuilder::PARAM_INT_ARRAY
|
||||
)))
|
||||
;
|
||||
|
||||
// WHERE these photos are in the user's requested folder recursively
|
||||
$query = $this->joinFilecache($query);
|
||||
|
|
Loading…
Reference in New Issue