23 lines
563 B
Python
23 lines
563 B
Python
|
|
import os
|
||
|
|
from functools import lru_cache
|
||
|
|
|
||
|
|
from adapters.postgres import connect
|
||
|
|
from adapters.postgres_query import PgReadingQueryRepository
|
||
|
|
from services.consumption_service import ConsumptionService
|
||
|
|
|
||
|
|
@lru_cache
|
||
|
|
def get_conn():
|
||
|
|
return connect(os.getenv("DATABASE_URL", "postgresql://simugaz:simugaz@db/simugaz"))
|
||
|
|
|
||
|
|
## Repositories
|
||
|
|
def get_query_repo() -> PgReadingQueryRepository:
|
||
|
|
return PgReadingQueryRepository(get_conn())
|
||
|
|
|
||
|
|
|
||
|
|
## Services
|
||
|
|
def get_consumption_service() -> ConsumptionService:
|
||
|
|
return ConsumptionService(get_query_repo())
|
||
|
|
|
||
|
|
|
||
|
|
## Adapters
|