Skip to content

feat: golang v2#26

Draft
Destinea wants to merge 202 commits into
masterfrom
feat/golang
Draft

feat: golang v2#26
Destinea wants to merge 202 commits into
masterfrom
feat/golang

Conversation

@Destinea

@Destinea Destinea commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Destinea and others added 30 commits April 22, 2026 23:53
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Validate day param in legendStatsDay to prevent BSON injection
- Generic JWT error message to avoid leaking internal details
- url.PathEscape for clan tags in war.go HTTP calls
- Goroutine semaphores in mobileFetchPlayersBasic (50) and mobileFetchWarSummariesByClan (20)
- N+1 → batch query in mobileFetchPlayerWarTimerClansBatch
- Handle cur.All() errors in tickets.go (links, players, users)
- Add projections on ClanDB and LeaderboardDB queries in leaderboards.go
- Propagate cur.All() errors in legend rankings, leaderboard, raid weekend
…tickets/open

Closes #27

The tickets/open endpoint was spending ~15s on live Discord member lookups
(64 users × rate-limited REST calls). This PR adds a shared Valkey cache
so the bot can populate member identities and the API reads from cache first.

- Add internal/utils/cache.go: CacheAdapter wrapping valkey-go client
  - Key format: discord:guild_member:{guild_id}:{user_id}
  - Supports positive entries (username/display_name/avatar_url) and
    negative entries (not_on_server: true) for confirmed-absent users
  - Degrades gracefully: no-op when REDIS_IP is unset or connection fails
- Add Cache *CacheAdapter to Deps; initialize in main.go; close on shutdown
- tickets.go: resolve missing identities from Valkey cache before falling
  back to live Discord API calls, reducing discord_ms from ~15s to near 0
  when cache is warm
- #300: initialise entries array on giveaway creation so the bot can push entries
- #275: use $unset instead of $set:null when clearing ticket panel channel fields
- #298: resolve internal UUIDs to Discord IDs in getLinks so Go-API-created accounts appear alongside legacy Python-bot accounts
Tests hit a live API at localhost:8000 and require SERVER_ID env var.
Run with: go test -tags integration ./test/integration/...
- #267: listRosterGroups now returns key "items" instead of "groups" so
  the dashboard fetchGroups function can read the list correctly
- #273: add recover() in warSummaryBulk goroutines so a panic in one
  clan's fetch cannot crash the whole server
…toboards

- #209: getAllRoles now includes category_roles from the server document
  alongside the existing status_roles, so clan category role assignments
  are visible in the all-roles endpoint
- #266: getAutoboards now checks each resolved channel against the Discord
  API and sets channel_deleted: true on items whose channel no longer exists
- #207: add GET /v2/server/:server_id/giveaways/:giveaway_id/entries
  returns each entrant with their entry count and win chance percentage
  (users with boosters appear multiple times in entries array, so counts
  reflect their actual weighted probability)
- #263: cap live Discord API lookups in getOpenTickets at 20 per request
  to prevent slow responses on servers with many uncached ticket users;
  users beyond the cap still appear in the list without display names
- Fix giveawayEntryCount using []any assertion instead of bson.A, causing entry count to always return 0
- Fix giveawayBoosters with same bson.A assertion bug
- Add CategoryRoles to RoleSettingsUpdate model to allow PATCH updates
- Support $set/$unset per-key dot-notation updates for category_roles in patchRoleSettings
- Return category_roles values as strings in getRoleSettings and getAllRoles to prevent JS precision loss on large Discord snowflake IDs
- Add categoryRolesStrings helper
- Remove erroneous #298 entry from BUGFIXES.txt (not a bug)
Add GiveawayEntrant and GiveawayEntriesResponse Pydantic models.
Add get_giveaway_entries endpoint that reads the entries array,
handles both plain user-ID strings and dict entries, counts each
user's entries via Counter, computes win_chance, and returns the
sorted entrant list.
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.

Add shared Discord member cache for dashboard/server endpoints

4 participants