refactor: move gisType to SystemConfig

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/888/head
Varun Patil 2023-10-22 13:37:50 -07:00
parent d5fcf19814
commit b3f8387a95
6 changed files with 17 additions and 13 deletions

View File

@ -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

View File

@ -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')

View File

@ -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) {

View File

@ -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;

View File

@ -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');
}
}

View File

@ -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.
*