From b3f8387a95aa349818e32e8dd66e5cd168650ff0 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 22 Oct 2023 13:37:50 -0700 Subject: [PATCH] refactor: move gisType to SystemConfig Signed-off-by: Varun Patil --- lib/ClustersBackend/PlacesBackend.php | 3 ++- lib/Db/TimelineQuerySingleItem.php | 3 ++- lib/Db/TimelineWritePlaces.php | 3 ++- lib/Service/Places.php | 3 ++- lib/Settings/SystemConfig.php | 9 +++++++++ lib/Util.php | 9 --------- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/ClustersBackend/PlacesBackend.php b/lib/ClustersBackend/PlacesBackend.php index 499e24ee..96e4b189 100644 --- a/lib/ClustersBackend/PlacesBackend.php +++ b/lib/ClustersBackend/PlacesBackend.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace OCA\Memories\ClustersBackend; use OCA\Memories\Db\TimelineQuery; +use OCA\Memories\Settings\SystemConfig; use OCA\Memories\Util; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IRequest; @@ -47,7 +48,7 @@ class PlacesBackend extends Backend public function isEnabled(): bool { - return Util::placesGISType() > 0; + return SystemConfig::gisType() > 0; } public function transformDayQuery(IQueryBuilder &$query, bool $aggregate): void diff --git a/lib/Db/TimelineQuerySingleItem.php b/lib/Db/TimelineQuerySingleItem.php index 06dd8ba8..c5e3a7d3 100644 --- a/lib/Db/TimelineQuerySingleItem.php +++ b/lib/Db/TimelineQuerySingleItem.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace OCA\Memories\Db; use OCA\Memories\ClustersBackend\PlacesBackend; +use OCA\Memories\Settings\SystemConfig; use OCA\Memories\Util; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -79,7 +80,7 @@ trait TimelineQuerySingleItem } // Get address from places - if (Util::placesGISType() > 0) { + if (SystemConfig::gisType() > 0) { // Get names of places for this file $qb = $this->connection->getQueryBuilder(); $places = $qb->select('e.name', 'e.other_names') diff --git a/lib/Db/TimelineWritePlaces.php b/lib/Db/TimelineWritePlaces.php index 5dd7c28c..c17b7ecd 100644 --- a/lib/Db/TimelineWritePlaces.php +++ b/lib/Db/TimelineWritePlaces.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace OCA\Memories\Db; +use OCA\Memories\Settings\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use Psr\Log\LoggerInterface; @@ -27,7 +28,7 @@ trait TimelineWritePlaces public function updatePlacesData(int $fileId, ?float $lat, ?float $lon): array { // Get GIS type - $gisType = \OCA\Memories\Util::placesGISType(); + $gisType = SystemConfig::gisType(); // Check if valid if ($gisType <= 0) { diff --git a/lib/Service/Places.php b/lib/Service/Places.php index 7ca966be..0bff72de 100644 --- a/lib/Service/Places.php +++ b/lib/Service/Places.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace OCA\Memories\Service; use OCA\Memories\Db\TimelineWrite; +use OCA\Memories\Settings\SystemConfig; use OCP\IConfig; use OCP\IDBConnection; @@ -89,7 +90,7 @@ class Places public function queryPoint(float $lat, float $lon): array { // Get GIS type - $gisType = \OCA\Memories\Util::placesGISType(); + $gisType = SystemConfig::gisType(); // Construct WHERE clause depending on GIS type $where = null; diff --git a/lib/Settings/SystemConfig.php b/lib/Settings/SystemConfig.php index 42122710..28c8fb4e 100644 --- a/lib/Settings/SystemConfig.php +++ b/lib/Settings/SystemConfig.php @@ -157,4 +157,13 @@ class SystemConfig $config->setSystemValue($key, $value); } } + + /** + * Check if geolocation (places) is enabled and available. + * Returns the type of the GIS. + */ + public static function gisType(): int + { + return self::get('memories.gis_type'); + } } diff --git a/lib/Util.php b/lib/Util.php index 20a90355..160bdf86 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -316,15 +316,6 @@ class Util return false; } - /** - * Check if geolocation (places) is enabled and available. - * Returns the type of the GIS. - */ - public static function placesGISType(): int - { - return SystemConfig::get('memories.gis_type'); - } - /** * Get list of timeline paths as array. *