Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions lib/Controller/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ private function isNewAddress($prevGeo, $geo) {
}

/**
* get distance between two geo points
* @param GPS coordinates of first point
* @param GPS coordinates of second point
* Get distance between two geo points.
*
* @param array $coordsA GPS coordinates of first point
* @param array $coordsB GPS coordinates of second point
* @return float Distance in meters between these two points
*/
private function getDistance($coordsA, $coordsB) {
private function getDistance(array $coordsA, array $coordsB) {
if (empty($coordsA) || empty($coordsB)) {
return 9E999;
}
Expand Down Expand Up @@ -674,7 +675,7 @@ private function setAddressCoordinates(float $lat, float $lng, string $adr, stri
->from('maps_address_geo')
->where($qb->expr()->eq('adr_norm', $qb->createNamedParameter($adr_norm, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq('object_uri', $qb->createNamedParameter($uri, IQueryBuilder::PARAM_STR)));
$req = $qb->execute();
$req = $qb->executeQuery();
$result = $req->fetchAll();
$req->closeCursor();
$qb = $this->dbconnection->getQueryBuilder();
Expand All @@ -686,8 +687,7 @@ private function setAddressCoordinates(float $lat, float $lng, string $adr, stri
->set('object_uri', $qb->createNamedParameter($uri, IQueryBuilder::PARAM_STR))
->set('looked_up', $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL))
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_STR)));
$req = $qb->execute();

$qb->executeStatement();
} else {
$qb->insert('maps_address_geo')
->values([
Expand All @@ -698,8 +698,7 @@ private function setAddressCoordinates(float $lat, float $lng, string $adr, stri
'lng' => $qb->createNamedParameter($lng, IQueryBuilder::PARAM_STR),
'looked_up' => $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL),
]);
$req = $qb->execute();
$id = $qb->getLastInsertId();
$qb->executeStatement();
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version000013Date20190723185417.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
$query = $this->db->getQueryBuilder();
$query->delete('maps_address_geo');
$query->execute();
$query->executeStatement();
}
}
16 changes: 8 additions & 8 deletions lib/Service/AddressService.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function lookupAddress($adr, $uri): array {
->from('maps_address_geo')
->where($qb->expr()->eq('object_uri', $qb->createNamedParameter($uri, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq('adr_norm', $qb->createNamedParameter($adr_norm, IQueryBuilder::PARAM_STR)));
$req = $qb->execute();
$req = $qb->executeQuery();
$lat = null;
$lng = null;
$inDb = false;
Expand Down Expand Up @@ -131,7 +131,7 @@ public function lookupAddress($adr, $uri): array {
->set('object_uri', $qb->createNamedParameter($uri, IQueryBuilder::PARAM_STR))
->set('looked_up', $qb->createNamedParameter($lookedUp, IQueryBuilder::PARAM_BOOL))
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_STR)));
$req = $qb->execute();
$qb->executeStatement();
}
}

Expand All @@ -156,7 +156,7 @@ private function lookupAddressInternal($adr): array {
->from('maps_address_geo')
->where($qb->expr()->eq('looked_up', $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->eq('adr_norm', $qb->createNamedParameter($adr_norm, IQueryBuilder::PARAM_STR)));
$req = $qb->execute();
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
$res[0] = $row['lat'];
$res[1] = $row['lng'];
Expand Down Expand Up @@ -249,7 +249,7 @@ private function cleanUpDBContactAddresses($vCard, $uri) {
$qb->select('id', 'adr')
->from('maps_address_geo')
->where($qb->expr()->eq('object_uri', $qb->createNamedParameter($uri, IQueryBuilder::PARAM_STR)));
$req = $qb->execute();
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
if (!in_array($row['adr'], $vCardAddresses)) {
array_push($adrIdToDelete, $row['id']);
Expand All @@ -263,7 +263,7 @@ private function cleanUpDBContactAddresses($vCard, $uri) {
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb->executeStatement();
}
}

Expand All @@ -273,7 +273,7 @@ public function deleteDBContactAddresses($uri) {
->where(
$qb->expr()->eq('object_uri', $qb->createNamedParameter($uri, IQueryBuilder::PARAM_STR))
);
$req = $qb->execute();
$qb->executeStatement();
}

// schedules the address for an external lookup
Expand All @@ -294,7 +294,7 @@ private function scheduleForLookup($adr, $uri): array {
'lng' => $qb->createNamedParameter($geo[1], IQueryBuilder::PARAM_STR),
'looked_up' => $qb->createNamedParameter($geo[2], IQueryBuilder::PARAM_BOOL),
]);
$req = $qb->execute();
$qb->executeStatement();
$id = $qb->getLastInsertId();
if (!$geo[2]) {
$this->jobList->add(LookupMissingGeoJob::class, []);
Expand All @@ -312,7 +312,7 @@ public function lookupMissingGeo($max = 200):bool {
->from('maps_address_geo')
->where($qb->expr()->eq('looked_up', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->setMaxResults($max);
$req = $qb->execute();
$req = $qb->executeQuery();
$result = $req->fetchAll();
$req->closeCursor();
$i = 0;
Expand Down
28 changes: 14 additions & 14 deletions lib/Service/DevicesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getDevicesFromDB($userId) {
->where(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
);
$req = $qb->execute();
$req = $qb->executeQuery();

while ($row = $req->fetch()) {
$devices[intval($row['id'])] = [
Expand Down Expand Up @@ -88,7 +88,7 @@ public function getDevicesByTokens(array $tokens) {
->where(
$qb->expr()->in('s.token', $qb->createNamedParameter($tokens, IQueryBuilder::PARAM_STR_ARRAY))
);
$req = $qb->execute();
$req = $qb->executeQuery();

while ($row = $req->fetch()) {
if (array_key_exists(intval($row['id']), $devices)) {
Expand Down Expand Up @@ -144,7 +144,7 @@ public function getDevicePointsFromDB($userId, $deviceId, ?int $pruneBefore = 0,
$qb->setMaxResults($limit);
}
$qb->orderBy('timestamp', 'DESC');
$req = $qb->execute();
$req = $qb->executeQuery();

$points = [];
while ($row = $req->fetch()) {
Expand Down Expand Up @@ -199,7 +199,7 @@ public function getDevicePointsByTokens(array $tokens, ?int $pruneBefore = 0, ?i
$qb->setMaxResults($limit);
}
$qb->orderBy('timestamp', 'DESC');
$req = $qb->execute();
$req = $qb->executeQuery();

$points = [];
while ($row = $req->fetch()) {
Expand Down Expand Up @@ -237,7 +237,7 @@ public function getDeviceTimePointsFromDb($userId, $deviceId) {
$qb->expr()->eq('d.user_id', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
);
$qb->orderBy('timestamp', 'ASC');
$req = $qb->execute();
$req = $qb->executeQuery();

$points = [];
while ($row = $req->fetch()) {
Expand All @@ -258,7 +258,7 @@ public function getOrCreateDeviceFromDB($userId, $userAgent) {
->andWhere(
$qb->expr()->eq('user_agent', $qb->createNamedParameter($userAgent, IQueryBuilder::PARAM_STR))
);
$req = $qb->execute();
$req = $qb->executeQuery();

while ($row = $req->fetch()) {
$deviceId = intval($row['id']);
Expand All @@ -272,7 +272,7 @@ public function getOrCreateDeviceFromDB($userId, $userAgent) {
'user_agent' => $qb->createNamedParameter($userAgent, IQueryBuilder::PARAM_STR),
'user_id' => $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR)
]);
$req = $qb->execute();
$qb->executeStatement();
$deviceId = $qb->getLastInsertId();
}
return $deviceId;
Expand All @@ -290,7 +290,7 @@ public function addPointToDB($deviceId, $lat, $lng, $ts, $altitude, $battery, $a
'battery' => $qb->createNamedParameter(is_numeric($battery) ? $battery : null, IQueryBuilder::PARAM_STR),
'accuracy' => $qb->createNamedParameter(is_numeric($accuracy) ? $accuracy : null, IQueryBuilder::PARAM_STR)
]);
$req = $qb->execute();
$qb->executeStatement();
$pointId = $qb->getLastInsertId();
return $pointId;
}
Expand Down Expand Up @@ -332,7 +332,7 @@ public function getDeviceFromDB($id, $userId) {
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
);
}
$req = $qb->execute();
$req = $qb->executeQuery();

while ($row = $req->fetch()) {
$device = [
Expand All @@ -358,7 +358,7 @@ public function editDeviceInDB($id, $color, $name) {
$qb->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb->executeStatement();
}

public function deleteDeviceFromDB($id) {
Expand All @@ -367,13 +367,13 @@ public function deleteDeviceFromDB($id) {
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb->executeStatement();

$qb->delete('maps_device_points')
->where(
$qb->expr()->eq('device_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb->executeStatement();
}

public function countPoints($userId, $deviceIdList, $begin, $end) {
Expand Down Expand Up @@ -403,7 +403,7 @@ public function countPoints($userId, $deviceIdList, $begin, $end) {
$qb->expr()->lt('p.timestamp', $qb->createNamedParameter(intval($end), IQueryBuilder::PARAM_INT))
);
}
$req = $qb->execute();
$req = $qb->executeQuery();
$count = 0;
while ($row = $req->fetch()) {
$count = intval($row['co']);
Expand Down Expand Up @@ -487,7 +487,7 @@ private function getAndWriteDevicePoints($devid, $begin, $end, $fd, $nbPoints, $
$qb->setFirstResult($pointIndex);
$qb->setMaxResults($chunkSize);
$qb->orderBy('timestamp', 'ASC');
$req = $qb->execute();
$req = $qb->executeQuery();

while ($row = $req->fetch()) {
$id = intval($row['id']);
Expand Down
Loading
Loading