tw: wrap map ops in transaction

pull/460/head
Varun Patil 2023-02-24 01:38:31 -08:00
parent eb51b59152
commit fe0de6e9cb
1 changed files with 12 additions and 0 deletions

View File

@ -82,6 +82,8 @@ trait TimelineWriteMap
return; return;
} }
$this->connection->beginTransaction();
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->update('memories_mapclusters') $query->update('memories_mapclusters')
->set('point_count', $query->createFunction('point_count + 1')) ->set('point_count', $query->createFunction('point_count + 1'))
@ -92,6 +94,8 @@ trait TimelineWriteMap
$query->executeStatement(); $query->executeStatement();
$this->mapUpdateAggregates($clusterId); $this->mapUpdateAggregates($clusterId);
$this->connection->commit();
} }
/** /**
@ -104,6 +108,8 @@ trait TimelineWriteMap
*/ */
private function mapCreateCluster(float $lat, float $lon): int private function mapCreateCluster(float $lat, float $lon): int
{ {
$this->connection->beginTransaction();
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->insert('memories_mapclusters') $query->insert('memories_mapclusters')
->values([ ->values([
@ -117,6 +123,8 @@ trait TimelineWriteMap
$clusterId = (int) $query->getLastInsertId(); $clusterId = (int) $query->getLastInsertId();
$this->mapUpdateAggregates($clusterId); $this->mapUpdateAggregates($clusterId);
$this->connection->commit();
return $clusterId; return $clusterId;
} }
@ -133,6 +141,8 @@ trait TimelineWriteMap
return; return;
} }
$this->connection->beginTransaction();
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->update('memories_mapclusters') $query->update('memories_mapclusters')
->set('point_count', $query->createFunction('point_count - 1')) ->set('point_count', $query->createFunction('point_count - 1'))
@ -143,6 +153,8 @@ trait TimelineWriteMap
$query->executeStatement(); $query->executeStatement();
$this->mapUpdateAggregates($clusterId); $this->mapUpdateAggregates($clusterId);
$this->connection->commit();
} }
/** /**