Add CP→CA→PI platform foundation on MapMil monorepo.
Unify parsing workers, analytics API with PostgreSQL, map UI, and PI distribution into centers/ with Docker Compose. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import os
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from .models import Consumer, ConsumerFilter, MapObject
|
||||
from .services.filtering import hash_api_key
|
||||
|
||||
SEED_OBJECTS = [
|
||||
{
|
||||
"name": "Красная площадь",
|
||||
"description": "Главная площадь Москвы, исторический центр города.",
|
||||
"type": "marker",
|
||||
"latitude": 55.7539,
|
||||
"longitude": 37.6208,
|
||||
"created_at": datetime(2018, 5, 9, 12, 0, tzinfo=timezone.utc),
|
||||
},
|
||||
{
|
||||
"name": "ВДНХ",
|
||||
"description": "Выставка достижений народного хозяйства — крупный выставочный комплекс.",
|
||||
"type": "zone",
|
||||
"latitude": 55.8298,
|
||||
"longitude": 37.6361,
|
||||
"created_at": datetime(2020, 8, 15, 10, 30, tzinfo=timezone.utc),
|
||||
},
|
||||
{
|
||||
"name": "МГУ",
|
||||
"description": "Московский государственный университет имени М.В. Ломоносова.",
|
||||
"type": "point",
|
||||
"latitude": 55.7033,
|
||||
"longitude": 37.5307,
|
||||
"created_at": datetime(2022, 2, 12, 14, 0, tzinfo=timezone.utc),
|
||||
},
|
||||
{
|
||||
"name": "Парк Горького",
|
||||
"description": "Центральный парк культуры и отдыха имени М. Горького.",
|
||||
"type": "other",
|
||||
"latitude": 55.7312,
|
||||
"longitude": 37.6013,
|
||||
"created_at": datetime(2024, 6, 1, 9, 0, tzinfo=timezone.utc),
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def seed_objects(db: Session) -> None:
|
||||
if db.query(MapObject).count() > 0:
|
||||
return
|
||||
|
||||
for item in SEED_OBJECTS:
|
||||
db.add(MapObject(**item))
|
||||
|
||||
db.commit()
|
||||
|
||||
|
||||
def seed_test_consumer(db: Session) -> None:
|
||||
if db.query(Consumer).filter(Consumer.name == "test-pi").first():
|
||||
return
|
||||
|
||||
api_key = os.getenv("TEST_PI_API_KEY", "test-pi-api-key-change-me")
|
||||
consumer = Consumer(
|
||||
name="test-pi",
|
||||
api_key_hash=hash_api_key(api_key),
|
||||
is_active=True,
|
||||
)
|
||||
db.add(consumer)
|
||||
db.flush()
|
||||
db.add(ConsumerFilter(consumer_id=consumer.id, regions=None, topics=None))
|
||||
db.commit()
|
||||
Reference in New Issue
Block a user