db.py
python
sha256:8e05daa29ba6702b4a2380a16d690ba31cc099d69c5c859bc6e6f16a0e945f99
Merge 'fix/deploy-memory-limits-and-log-group' into 'dev' —…
Human
9 days ago
| 1 | """DB helpers for MuseHub test fixtures. |
| 2 | |
| 3 | Provides insert_commit and upsert_snapshot for populating the |
| 4 | muse_commits table in tests. |
| 5 | """ |
| 6 | |
| 7 | import logging |
| 8 | |
| 9 | from muse.core.types import short_id |
| 10 | from sqlalchemy.ext.asyncio import AsyncSession |
| 11 | |
| 12 | from musehub.db.muse_cli_models import MuseCliCommit, MuseCliSnapshot |
| 13 | from musehub.types.json_types import StrDict |
| 14 | |
| 15 | logger = logging.getLogger(__name__) |
| 16 | |
| 17 | |
| 18 | async def upsert_snapshot( |
| 19 | session: AsyncSession, manifest: StrDict, snapshot_id: str |
| 20 | ) -> MuseCliSnapshot: |
| 21 | """Insert a MuseCliSnapshot row, ignoring duplicates.""" |
| 22 | existing = await session.get(MuseCliSnapshot, snapshot_id) |
| 23 | if existing is not None: |
| 24 | logger.debug("⚠️ Snapshot %s already exists — skipped", short_id(snapshot_id)) |
| 25 | return existing |
| 26 | snap = MuseCliSnapshot(snapshot_id=snapshot_id, manifest=manifest) |
| 27 | session.add(snap) |
| 28 | logger.debug("✅ New snapshot %s (%d files)", short_id(snapshot_id), len(manifest)) |
| 29 | return snap |
| 30 | |
| 31 | |
| 32 | async def insert_commit(session: AsyncSession, commit: MuseCliCommit) -> None: |
| 33 | """Insert a new MuseCliCommit row.""" |
| 34 | session.add(commit) |
| 35 | logger.debug("✅ New commit %s branch=%r", short_id(commit.commit_id), commit.branch) |
File History
3 commits
sha256:8e05daa29ba6702b4a2380a16d690ba31cc099d69c5c859bc6e6f16a0e945f99
Merge 'fix/deploy-memory-limits-and-log-group' into 'dev' —…
Human
9 days ago
sha256:3fadb0439bba9451b89229676971c0d4a40900dec7810e9d5f8791b8d950d505
fix: install.sh version from latest published tarball, not …
Sonnet 4.6
minor
⚠
100 days ago
sha256:763eb2cb8675073b84c19345b27586d2ed939a9aee97c5479b69f502f1a70eff
fix(tests): update test suite to match current implementation
Sonnet 4.6
patch
122 days ago