artifacts-dashboard/backend/app/models/price_history.py
Paweł Orzech f845647934
Some checks failed
Release / release (push) Has been cancelled
Initial release: Artifacts MMO Dashboard & Automation Platform
Full-stack dashboard for controlling, automating, and analyzing
Artifacts MMO characters via the game's HTTP API.

Backend (FastAPI):
- Async Artifacts API client with rate limiting and retry
- 6 automation strategies (combat, gathering, crafting, trading, task, leveling)
- Automation engine with runner, manager, cooldown tracker, pathfinder
- WebSocket relay (game server -> frontend)
- Game data cache, character snapshots, price history, analytics
- 9 API routers, 7 database tables, 3 Alembic migrations
- 108 unit tests

Frontend (Next.js 15 + shadcn/ui):
- Live character dashboard with HP/XP bars and cooldowns
- Character detail with stats, equipment, inventory, skills, manual actions
- Automation management with live log streaming
- Interactive canvas map with content-type coloring and zoom/pan
- Bank management, Grand Exchange with price charts
- Events, logs, analytics pages with Recharts
- WebSocket auto-reconnect with query cache invalidation
- Settings page, error boundaries, dark theme

Infrastructure:
- Docker Compose (dev + prod)
- GitHub Actions CI/CD
- Documentation (Architecture, Automation, Deployment, API)
2026-03-01 19:46:45 +01:00

49 lines
1.4 KiB
Python

from datetime import datetime
from sqlalchemy import DateTime, Float, Integer, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
class PriceHistory(Base):
"""Captured Grand Exchange price snapshots over time."""
__tablename__ = "price_history"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
item_code: Mapped[str] = mapped_column(
String(100),
nullable=False,
index=True,
comment="Item code from the Artifacts API",
)
buy_price: Mapped[float | None] = mapped_column(
Float,
nullable=True,
comment="Best buy price at capture time",
)
sell_price: Mapped[float | None] = mapped_column(
Float,
nullable=True,
comment="Best sell price at capture time",
)
volume: Mapped[int] = mapped_column(
Integer,
nullable=False,
default=0,
comment="Trade volume at capture time",
)
captured_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
nullable=False,
index=True,
comment="Timestamp when the price was captured",
)
def __repr__(self) -> str:
return (
f"<PriceHistory(id={self.id}, item={self.item_code!r}, "
f"buy={self.buy_price}, sell={self.sell_price})>"
)