Phase 9: division/season tracking, club customization, pack history, notifications
CI / Build, lint & test (push) Failing after 1m42s
CI / Build, lint & test (push) Failing after 1m42s
- GET /division returns live season stats (points, record, promotion threshold) - PUT /club allows updating club name and manager_name - GET /packs/history returns opened packs with full card definitions - GET /notifications dynamically surfaces completed objectives, expiring loans, season end - Club model gains manager_name column (migration 0006 already added it) - Pack model gains opened_cards and opened_at; pack SELECT queries updated - 9 new integration tests — all 45 pass, clippy clean Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+11
-3
@@ -39,6 +39,8 @@ pub async fn grant_pack(pool: &Pool, club_id: &str, definition_id: &str) -> AppR
|
||||
definition_id: definition_id.to_string(),
|
||||
opened: false,
|
||||
created_at: chrono::Utc::now().to_rfc3339(),
|
||||
opened_cards: None,
|
||||
opened_at: None,
|
||||
};
|
||||
sqlx::query(
|
||||
"INSERT INTO packs (id, club_id, definition_id, opened, created_at) VALUES (?, ?, ?, ?, ?)",
|
||||
@@ -61,7 +63,7 @@ pub async fn open_pack(
|
||||
pack_id: &str,
|
||||
) -> AppResult<PackOpenResult> {
|
||||
let pack = sqlx::query_as::<_, Pack>(
|
||||
"SELECT id, club_id, definition_id, opened, created_at FROM packs WHERE id = ? AND club_id = ?"
|
||||
"SELECT id, club_id, definition_id, opened, created_at, opened_cards, opened_at FROM packs WHERE id = ? AND club_id = ?"
|
||||
)
|
||||
.bind(pack_id)
|
||||
.bind(club_id)
|
||||
@@ -122,7 +124,13 @@ pub async fn open_pack(
|
||||
}
|
||||
}
|
||||
|
||||
sqlx::query("UPDATE packs SET opened = 1 WHERE id = ?")
|
||||
let card_ids_json = serde_json::to_string(&cards.iter().map(|c| &c.id).collect::<Vec<_>>())
|
||||
.unwrap_or_default();
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
|
||||
sqlx::query("UPDATE packs SET opened = 1, opened_cards = ?, opened_at = ? WHERE id = ?")
|
||||
.bind(&card_ids_json)
|
||||
.bind(&now)
|
||||
.bind(pack_id)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
@@ -152,7 +160,7 @@ pub async fn buy_pack(
|
||||
|
||||
pub async fn get_unopened_packs(pool: &Pool, club_id: &str) -> AppResult<Vec<Pack>> {
|
||||
let packs = sqlx::query_as::<_, Pack>(
|
||||
"SELECT id, club_id, definition_id, opened, created_at FROM packs WHERE club_id = ? AND opened = 0"
|
||||
"SELECT id, club_id, definition_id, opened, created_at, opened_cards, opened_at FROM packs WHERE club_id = ? AND opened = 0"
|
||||
)
|
||||
.bind(club_id)
|
||||
.fetch_all(pool)
|
||||
|
||||
Reference in New Issue
Block a user