Migrate location recorder and refine db config

This commit is contained in:
2026-04-19 21:39:23 +02:00
parent 31390882ef
commit 32cc6847fd
19 changed files with 507 additions and 31 deletions
+17 -8
View File
@@ -12,7 +12,8 @@ class Settings(BaseSettings):
app_host: str = "0.0.0.0"
app_port: int = 8000
database_url: str = "sqlite:///./data/app.db"
location_database_url: str = "sqlite:///./data/locationRecorder.db"
poo_database_url: str = "sqlite:///./data/pooRecorder.db"
ticktick_client_id: str = ""
ticktick_client_secret: str = ""
@@ -34,17 +35,25 @@ class Settings(BaseSettings):
def is_development(self) -> bool:
return self.app_env.lower() == "development"
@staticmethod
def _sqlite_path_from_url(database_url: str) -> Path | None:
prefix = "sqlite:///"
if not database_url.startswith(prefix):
return None
raw_path = database_url[len(prefix) :]
return Path(raw_path)
@computed_field
@property
def sqlite_path(self) -> Path | None:
prefix = "sqlite:///"
if not self.database_url.startswith(prefix):
return None
raw_path = self.database_url[len(prefix) :]
return Path(raw_path)
def location_sqlite_path(self) -> Path | None:
return self._sqlite_path_from_url(self.location_database_url)
@computed_field
@property
def poo_sqlite_path(self) -> Path | None:
return self._sqlite_path_from_url(self.poo_database_url)
@lru_cache
def get_settings() -> Settings:
return Settings()