feat: include animated_url in tier-up response for T3/T4 (#201) #208
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
autonomous
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
size:M
size:S
tech-debt
todo
type:feature
type:stability
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#208
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/201-feat-include-animated-url-in-tier-up-response-for"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #201
Summary
Adds
animated_urlto the tier-up response in thePOST /api/v2/refractor/evaluate-game/{game_id}endpoint for T3 and T4 tier-ups.Changes
app/routers_v2/refractor.py: Addedfrom datetime import dateimport; extended theif boost_result:block to setanimated_urlon the tier-up entry whencomputed_tier >= 3and a variant was created.Behaviour
For T3/T4 tier-ups where
boost_resultis present, the response now includes:The
animated_urlis constructed as:API_BASE_URLenv var controls the base (defaults to empty string, producing a relative URL). Set to e.g.https://pd.manticorum.com:815in production for an absolute URL the Discord bot can use directly.dis today's date (YYYY-MM-DD), matching the cache-bust convention in the S3 URL pipeline.animated_urlis absent (not included in the response).Other observations
animated_urlcould be updated to return the S3 URL instead of the API endpoint URL.AI Code Review
Files Reviewed
app/routers_v2/refractor.py(modified)Findings
Correctness
No issues found.
from datetime import dateadded at top-level — follows CLAUDE.md no-lazy-import rule ✅variant_numrefactor is clean;tier_up_entry["variant_created"]behavior unchanged ✅computed_tier >= 3 and variant_num and card_type: at this code pathcard_typeis always truthy (theelse: continueat line 457 ensures we never reachif boost_result:with a null card_type), so thecard_typecheck is redundant but harmless ✅{card_type}cardcorrectly yieldsbattingcard/pitchingcardmatching the/animatedendpoint path from PR #188 ✅computed_tierat the point of the guard reflects the last-committed tier (partial-failure path at line 456 setscomputed_tier = last_successful_tier), so a T3-succeeded / T4-failed partial boost correctly still generates a T3 animated_url ✅os.environ.get("API_BASE_URL", "")—oswas already imported at line 1; env var default produces a relative URL as documented ✅variant_numtruthiness: SHA-256 variants are remapped so 0→1 (see refractor_boost.py), making variant=0 theoretically impossible. Silently omitting animated_url if variant_num==0 is correct defensive behavior ✅Security
No issues found. URL is constructed entirely from server-controlled values (player_id from DB, card_type from DB state, date from server clock, variant_num from boost result). No user-controlled input in the URL.
Style & Conventions
No issues found.
Suggestions
card_typecheck inif computed_tier >= 3 and variant_num and card_type:is logically unreachable as a falsy value (see Correctness note above). It's harmless and adds defensive clarity, so no change needed.Verdict: COMMENT
Implementation is correct.
animated_urlis only emitted for T3/T4 boosts, the URL format matches the/animatedendpoint, env var configuration is sound, and the import follows project conventions. Self-review restriction prevents APPROVED — no blocking issues; ready to merge.Automated review by Claude PR Reviewer
Approved via pd-pr