Skip to content

feat(espn-service): expand API with news, injuries, transactions & at…#15

Merged
pseudo-r merged 2 commits into
mainfrom
Public-Api
Mar 23, 2026
Merged

feat(espn-service): expand API with news, injuries, transactions & at…#15
pseudo-r merged 2 commits into
mainfrom
Public-Api

Conversation

@pseudo-r

Copy link
Copy Markdown
Owner

…hlete stats

New Database Models

  • NewsArticle - stores ESPN news articles (site API + Now API), keyed on espn_id
  • Injury - league injury reports (snapshot-style refresh per league)
  • Transaction - signings, trades, waivers (upsert on espn_id)
  • AthleteSeasonStats - per-athlete season stats from common/v3 endpoint

Migration: 0002_injury_newsarticle_transaction_athleteseasonstats

New Ingestion Services (apps/ingest/services.py)

  • NewsIngestionService - update_or_create on espn_id
  • InjuryIngestionService - full snapshot delete+re-insert per league
  • TransactionIngestionService - update_or_create on espn_id
  • AthleteStatsIngestionService - update_or_create on composite key

New Celery Tasks + Beat Schedules

  • refresh_news_task / refresh_all_news_task (Beat: every 30 min)
  • refresh_injuries_task / refresh_all_injuries_task (Beat: every 4 hours)
  • refresh_transactions_task / refresh_all_transactions_task (Beat: every 6 hours)

New REST API Endpoints

GET /api/v1/news/ - filterable by sport, league, date_from, search
GET /api/v1/injuries/ - filterable by sport, league, status, team
GET /api/v1/transactions/ - filterable by sport, league, date_from
GET /api/v1/athlete-stats/ - filterable by sport, league, season, athlete_espn_id
POST /api/v1/ingest/news/ - manual news ingest trigger
POST /api/v1/ingest/injuries/ - manual injury snapshot trigger
POST /api/v1/ingest/transactions/ - manual transaction ingest trigger

New Management Commands

python manage.py ingest_news [--sport X --league Y] [--limit N]
python manage.py ingest_injuries [--sport X --league Y]
python manage.py ingest_transactions [--sport X --league Y]

Other Changes

  • Updated admin.py with list_display, list_filter, search for all 4 new models
  • Updated serializers (list + detail variants for news/injuries/transactions/athlete-stats)
  • Added docker-compose.test.yml for local Docker-based test runs
  • Added 21 new tests in tests/test_ingestion_new.py (145 total, all passing)
  • Added ESPN audit findings: 11 new espn_client methods, 6 API domains documented
  • Updated CELERY_BEAT_SCHEDULE in base.py with 3 new periodic task entries
  • Corrected standings endpoint bug (was using /apis/site/v2/, now /apis/v2/)
  • Expanded ALL_LEAGUES_CONFIG to cover 50+ league slugs across 12 sports

…hlete stats

## New Database Models
- NewsArticle  - stores ESPN news articles (site API + Now API), keyed on espn_id
- Injury       - league injury reports (snapshot-style refresh per league)
- Transaction  - signings, trades, waivers (upsert on espn_id)
- AthleteSeasonStats - per-athlete season stats from common/v3 endpoint

Migration: 0002_injury_newsarticle_transaction_athleteseasonstats

## New Ingestion Services (apps/ingest/services.py)
- NewsIngestionService         - update_or_create on espn_id
- InjuryIngestionService       - full snapshot delete+re-insert per league
- TransactionIngestionService  - update_or_create on espn_id
- AthleteStatsIngestionService - update_or_create on composite key

## New Celery Tasks + Beat Schedules
- refresh_news_task / refresh_all_news_task         (Beat: every 30 min)
- refresh_injuries_task / refresh_all_injuries_task (Beat: every 4 hours)
- refresh_transactions_task / refresh_all_transactions_task (Beat: every 6 hours)

## New REST API Endpoints
GET  /api/v1/news/              - filterable by sport, league, date_from, search
GET  /api/v1/injuries/          - filterable by sport, league, status, team
GET  /api/v1/transactions/      - filterable by sport, league, date_from
GET  /api/v1/athlete-stats/     - filterable by sport, league, season, athlete_espn_id
POST /api/v1/ingest/news/       - manual news ingest trigger
POST /api/v1/ingest/injuries/   - manual injury snapshot trigger
POST /api/v1/ingest/transactions/ - manual transaction ingest trigger

## New Management Commands
  python manage.py ingest_news [--sport X --league Y] [--limit N]
  python manage.py ingest_injuries [--sport X --league Y]
  python manage.py ingest_transactions [--sport X --league Y]

## Other Changes
- Updated admin.py with list_display, list_filter, search for all 4 new models
- Updated serializers (list + detail variants for news/injuries/transactions/athlete-stats)
- Added docker-compose.test.yml for local Docker-based test runs
- Added 21 new tests in tests/test_ingestion_new.py (145 total, all passing)
- Added ESPN audit findings: 11 new espn_client methods, 6 API domains documented
- Updated CELERY_BEAT_SCHEDULE in base.py with 3 new periodic task entries
- Corrected standings endpoint bug (was using /apis/site/v2/, now /apis/v2/)
- Expanded ALL_LEAGUES_CONFIG to cover 50+ league slugs across 12 sports
…d Docker testing

- Expanded API Endpoints table: added /api/v1/news/, /api/v1/injuries/,
  /api/v1/transactions/, /api/v1/athlete-stats/ (GET + detail)
- Added Ingest Triggers sub-section with all 5 POST endpoints
- Added Database Models table covering all 11 models with ingestion source
- Added Celery Beat Schedule reference table
- Added Management Commands section with ingest_news / ingest_injuries /
  ingest_transactions examples
- Added Docker Testing section with docker-compose.test.yml usage
- Updated Example Usage curl examples to include injuries and news
@pseudo-r pseudo-r merged commit 9560ec3 into main Mar 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant