fix: add missing week field to scout reward POST #75

Merged
cal merged 1 commits from fix/scout-reward-week into main 2026-03-09 15:22:23 +00:00
Owner

Summary

  • The rewards API requires a week field in the request body
  • The scout claim callback in scout_view.py was posting without it, causing a 422 validation error when a user selected a card from a scout opportunity
  • Fix fetches current['week'] via db_get("current") before posting — same pattern used by daily check-in and game rewards
  • Added db_get mock to the happy-path test

Files Changed

  • discord_ui/scout_view.py — added db_get import, fetch current week, include week in payload
  • tests/scouting/test_scout_view.py — added db_get mock to test_successful_scout_creates_card_copy

Test Plan

  • All 27 scout view tests pass
  • Deploy and re-send scout opportunity #1 (pack 26011, team 31) to verify end-to-end
## Summary - The rewards API requires a `week` field in the request body - The scout claim callback in `scout_view.py` was posting without it, causing a 422 validation error when a user selected a card from a scout opportunity - Fix fetches `current['week']` via `db_get("current")` before posting — same pattern used by daily check-in and game rewards - Added `db_get` mock to the happy-path test ## Files Changed - `discord_ui/scout_view.py` — added `db_get` import, fetch current week, include `week` in payload - `tests/scouting/test_scout_view.py` — added `db_get` mock to `test_successful_scout_creates_card_copy` ## Test Plan - [x] All 27 scout view tests pass - [ ] Deploy and re-send scout opportunity #1 (pack 26011, team 31) to verify end-to-end
cal added 23 commits 2026-03-09 15:19:17 +00:00
When a player opens a pack, a scout opportunity is posted to #pack-openings
with face-down card buttons. Other players can blind-pick one card using
daily scout tokens (2/day), receiving a copy. The opener keeps all cards.

New files:
- discord_ui/scout_view.py: ScoutView with dynamic buttons and claim logic
- helpers/scouting.py: create_scout_opportunity() and embed builder
- cogs/economy_new/scouting.py: /scout-tokens command and cleanup task

Modified:
- helpers/main.py: Hook into open_st_pr_packs() after display_cards()
- paperdynasty.py: Register scouting cog

Requires new API endpoints in paper-dynasty-database (scout_opportunities).
Tracks #44.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Consolidate SCOUT_TOKENS_PER_DAY and get_scout_tokens_used() into
  helpers/scouting.py (was duplicated across 3 files)
- Add midnight_timestamp() utility to helpers/utils.py
- Remove _build_scouted_ids() wrapper, use self.claims directly
- Fix build_scout_embed return type annotation
- Use Discord <t:UNIX:R> relative timestamps for scout window countdown
- Add 66-test suite covering helpers, ScoutView, and cog

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix int_timestamp() no-arg path returning seconds instead of
  milliseconds, which would silently break the daily scout token cap
  against the real API
- Acknowledge double-click interactions with ephemeral message instead
  of silently returning (Discord requires all interactions to be acked)
- Reorder scout flow: create card copy before consuming token so a
  failure doesn't cost the player a token for nothing
- Move build_scouted_card_list import to top of scout_view.py
- Remove unused asyncio import from helpers/scouting.py
- Fix footer text inconsistency ("One scout per player" everywhere)
- Update tests for new operation order and double-click behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewed-on: #50
fix: update owner_only to use Cal's correct Discord ID
All checks were successful
Build Docker Image / build (push) Successful in 1m22s
ed00a97c0d
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: align scouting rarity symbols with system colors
All checks were successful
Build Docker Image / build (push) Successful in 1m22s
77c3f3004c
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: add pack_id to scouted card creation, enhance embed with card links
All checks were successful
Build Docker Image / build (push) Successful in 1m16s
8e605c2140
- Include pack_id in db_post("cards") payload (API requires it)
- Player names now link to card image URLs in scout embed
- Display format: "🟡 All-Star — [2023 Mike Trout](card_image_url)"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: add missing pack, description, image fields to scouting test fixtures
All checks were successful
Build Docker Image / build (push) Successful in 51s
e160be4137
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: limit scouting to Standard/Premium packs, simplify scout view
All checks were successful
Build Docker Image / build (push) Successful in 1m17s
da55cbe4d4
- Add SCOUTABLE_PACK_TYPES env var (default: Standard,Premium) to control
  which pack types offer scout opportunities
- Unify embed construction into build_scout_embed() — removes 3 near-duplicate
  embed builders across scout_view.py and scouting.py
- Replace manual total_scouts counter with derived property from claims dict
- Remove redundant db_get("current") API call per scout click — use PD_SEASON
- Remove duplicate expiry computation in create_scout_opportunity
- Move send_to_channel to top-level import, remove redundant local import
- Update tests to match simplified code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backup file was checked in with unused imports (requests, pygsheets),
adding noise to git grep, IDEs, and code review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous test patched api_calls.db_get and pygsheets.authorize then
called those mocks directly—never invoking any cog method. The test
passed even when all cog code was deleted.

Replace with a test that retrieves the real pull_roster_command.callback
from the cog instance, patches dependencies at the correct module-level
names, calls the callback, and asserts ctx.send was called with the
expected error message. If the cog cannot be imported, the test skips
gracefully via pytest.skip.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DNS failures and refused connections raised raw aiohttp errors to Discord
users. Added except aiohttp.ClientError handlers to db_get, db_patch,
db_post, db_put, and db_delete — each logs the error and raises
DatabaseError for consistent handling upstream.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove master_debug = True and replace all conditional INFO/DEBUG log
calls with unconditional logger.debug(). Also switches log_return_value
to logger.debug and removes the associated dead commented-out code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewed-on: #53
Reviewed-on: #54
Reviewed-on: #56
Reviewed-on: #57
Merge pull request 'fix: remove hardcoded master_debug flag from api_calls.py (#28)' (#58) from ai/paper-dynasty-discord-28 into next-release
All checks were successful
Build Docker Image / build (push) Successful in 1m5s
Build Docker Image / build (pull_request) Successful in 1m33s
1c3ef0935e
Reviewed-on: #58
fix: add missing week field to scout reward POST
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m22s
c875cee9ee
The rewards API requires a week field. The scout claim callback was
posting without it, causing a 422 validation error when a user
selected a card from a scout opportunity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cal force-pushed fix/scout-reward-week from c875cee9ee to 3e9c2f6564 2026-03-09 15:20:30 +00:00 Compare
cal merged commit 9d9b30e2fc into main 2026-03-09 15:22:23 +00:00
cal deleted branch fix/scout-reward-week 2026-03-09 15:22:23 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#75
No description provided.