Fix admin import chain and tests
This commit is contained in:
+37
-7
@@ -2,15 +2,9 @@ from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
||||
import os
|
||||
|
||||
DATABASE_URL = os.getenv(
|
||||
"DATABASE_URL",
|
||||
"postgresql://postgres:postgres@postgres:5432/vector_mchs"
|
||||
)
|
||||
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@postgres:5432/vector_mchs")
|
||||
engine = create_engine(DATABASE_URL, echo=False)
|
||||
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
@@ -24,3 +18,39 @@ def get_db():
|
||||
|
||||
def init_db():
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
|
||||
class _CompatDB:
|
||||
def __init__(self):
|
||||
self._cases = []
|
||||
|
||||
def create_case(self, **data):
|
||||
raise NotImplementedError('compat db is for import only')
|
||||
|
||||
def list_cases(self):
|
||||
return []
|
||||
|
||||
def get_case(self, case_id):
|
||||
return None
|
||||
|
||||
def update_case(self, case_id, **patch):
|
||||
return None
|
||||
|
||||
def delete_case(self, case_id):
|
||||
return False
|
||||
|
||||
def stats(self):
|
||||
return {
|
||||
'total_cases': 0,
|
||||
'found_alive_count': 0,
|
||||
'found_deceased_count': 0,
|
||||
'unknown_outcome_count': 0,
|
||||
'median_found_distance_km': None,
|
||||
'recent_activity_count': 0,
|
||||
}
|
||||
|
||||
def heatmap(self):
|
||||
return []
|
||||
|
||||
|
||||
db = _CompatDB()
|
||||
|
||||
Reference in New Issue
Block a user