File size: 3,062 Bytes
1ce499f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | from datetime import datetime
from sqlalchemy import String, Float, Integer, DateTime, Text, Boolean
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
class SpaceObject(Base):
__tablename__="space_objects"
object_id:Mapped[str]=mapped_column(String(64), primary_key=True)
norad_cat_id:Mapped[int|None]=mapped_column(Integer, index=True, nullable=True)
object_name:Mapped[str]=mapped_column(String(255), index=True)
object_type:Mapped[str|None]=mapped_column(String(64), nullable=True)
mean_motion:Mapped[float|None]=mapped_column(Float, nullable=True)
inclination:Mapped[float|None]=mapped_column(Float, nullable=True)
eccentricity:Mapped[float|None]=mapped_column(Float, nullable=True)
raan:Mapped[float|None]=mapped_column(Float, nullable=True)
bstar:Mapped[float|None]=mapped_column(Float, nullable=True)
launch_year:Mapped[int|None]=mapped_column(Integer, nullable=True)
inserted_at:Mapped[datetime]=mapped_column(DateTime, default=datetime.utcnow)
class PairScore(Base):
__tablename__="pair_scores"
pair_id:Mapped[str]=mapped_column(String(128), primary_key=True)
primary_object_id:Mapped[str]=mapped_column(String(64), index=True)
secondary_object_id:Mapped[str]=mapped_column(String(64), index=True)
latest_run_id:Mapped[str]=mapped_column(String(64), index=True)
risk_score:Mapped[float]=mapped_column(Float, index=True)
anomaly_score:Mapped[float]=mapped_column(Float, index=True)
final_score:Mapped[float]=mapped_column(Float, index=True)
risk_label:Mapped[str]=mapped_column(String(32), index=True)
recurrence_count:Mapped[int]=mapped_column(Integer, default=1)
trend_delta_24h:Mapped[float|None]=mapped_column(Float, nullable=True)
shell_key:Mapped[str|None]=mapped_column(String(128), index=True, nullable=True)
top_factors_json:Mapped[str]=mapped_column(Text)
feature_payload_json:Mapped[str]=mapped_column(Text)
updated_at:Mapped[datetime]=mapped_column(DateTime, default=datetime.utcnow)
class PairScoreHistory(Base):
__tablename__="pair_score_history"
history_id:Mapped[str]=mapped_column(String(128), primary_key=True)
pair_id:Mapped[str]=mapped_column(String(128), index=True)
run_id:Mapped[str]=mapped_column(String(64), index=True)
risk_score:Mapped[float]=mapped_column(Float)
anomaly_score:Mapped[float]=mapped_column(Float)
final_score:Mapped[float]=mapped_column(Float)
created_at:Mapped[datetime]=mapped_column(DateTime, default=datetime.utcnow)
class ScoringRun(Base):
__tablename__="scoring_runs"
run_id:Mapped[str]=mapped_column(String(64), primary_key=True)
source:Mapped[str]=mapped_column(String(64))
object_count:Mapped[int]=mapped_column(Integer, default=0)
candidate_pair_count:Mapped[int]=mapped_column(Integer, default=0)
scored_pair_count:Mapped[int]=mapped_column(Integer, default=0)
completed:Mapped[bool]=mapped_column(Boolean, default=False)
created_at:Mapped[datetime]=mapped_column(DateTime, default=datetime.utcnow)
|