Skip to content

Commit

Permalink
updated mariadb deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Delyc committed Aug 29, 2024
2 parents 923086c + d8c4588 commit 575a5a7
Show file tree
Hide file tree
Showing 285 changed files with 751 additions and 3,540 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public function sync()
'mpm_mini_grid_id' => $miniGrid->id,
'hash' => $site['hash'],
]);
$this->updateGeographicalInformation($miniGrid->id, $site);
$this->createOrUpdateGeographicalInformation($miniGrid->id, $site);
});

$syncCheck['data']->filter(function ($value) {
return $value['syncStatus'] === SyncStatus::MODIFIED;
})->each(function ($site) {
$miniGrid = is_null($site['relatedMiniGrid']) ?
$this->creteRelatedMiniGrid($site) : $this->updateRelatedMiniGrid($site, $site['relatedMiniGrid']);
$this->updateGeographicalInformation($miniGrid->id, $site);
$this->createOrUpdateGeographicalInformation($miniGrid->id, $site);
$site['registeredStmSite']->update([
'site_id' => $site['id'],
'mpm_mini_grid_id' => $miniGrid->id,
Expand Down Expand Up @@ -176,7 +176,7 @@ public function updateRelatedMiniGrid($site, $miniGrid)
return $miniGrid->fresh();
}

public function updateGeographicalInformation($miniGridId, $site)
public function createOrUpdateGeographicalInformation($miniGridId, $site)
{
$geographicalInformation = $this->geographicalInformation->newQuery()->whereHasMorph(
'owner',
Expand All @@ -187,9 +187,18 @@ static function ($q) use ($miniGridId) {
)->first();
$points = $site['latitude'] === null ?
config('steama.geoLocation') : $site['latitude'].','.$site['longitude'];
$geographicalInformation->update([
'points' => $points,
]);

if ($geographicalInformation) {
$geographicalInformation->update([
'points' => $points,
]);
} else {
$this->geographicalInformation->create([
'owner_type' => 'mini-grid',
'owner_id' => $miniGridId,
'points' => $points,
]);
}
}

public function checkLocationAvailability()
Expand Down
Loading

0 comments on commit 575a5a7

Please sign in to comment.