mirror of
https://github.com/bnair123/MusicAnalyser.git
synced 2026-02-25 11:46:07 +00:00
- Created `frontend/` React+Vite app using Ant Design (Dark Theme). - Implemented `App.jsx` to display listening history and calculated "Vibes". - Updated `backend/app/ingest.py` to fix ReccoBeats ID parsing. - Updated `backend/app/schemas.py` to expose audio features to the API. - Updated `README.md` with detailed Docker hosting instructions. - Added `TODO.md` for Phase 3 roadmap. - Cleaned up test scripts.
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from sqlalchemy.orm import Session
|
|
from app.database import SessionLocal, engine, Base
|
|
from app.models import Track, PlayHistory
|
|
from datetime import datetime, timedelta
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
db = SessionLocal()
|
|
|
|
# clear
|
|
db.query(PlayHistory).delete()
|
|
db.query(Track).delete()
|
|
db.commit()
|
|
|
|
# Create tracks
|
|
t1 = Track(id="t1", name="Midnight City", artist="M83", album="Hurry Up, We're Dreaming", duration_ms=243000, danceability=0.6, energy=0.8, valence=0.5, raw_data={})
|
|
t2 = Track(id="t2", name="Weightless", artist="Marconi Union", album="Weightless", duration_ms=480000, danceability=0.2, energy=0.1, valence=0.1, raw_data={})
|
|
t3 = Track(id="t3", name="Levitating", artist="Dua Lipa", album="Future Nostalgia", duration_ms=203000, danceability=0.8, energy=0.9, valence=0.9, raw_data={})
|
|
|
|
db.add_all([t1, t2, t3])
|
|
db.commit()
|
|
|
|
# Create history
|
|
ph1 = PlayHistory(track_id="t1", played_at=datetime.utcnow() - timedelta(minutes=10))
|
|
ph2 = PlayHistory(track_id="t2", played_at=datetime.utcnow() - timedelta(minutes=30))
|
|
ph3 = PlayHistory(track_id="t3", played_at=datetime.utcnow() - timedelta(minutes=60))
|
|
|
|
db.add_all([ph1, ph2, ph3])
|
|
db.commit()
|
|
|
|
print("Data populated")
|
|
db.close()
|