Skip to content

Add the activity command: weekly player activity totals for a region group - #104

Merged
valzargaming merged 1 commit into
mainfrom
claude/project-thread-9lfiol
Nov 16, 2026
Merged

valzargaming merged 1 commit into
mainfrom
claude/project-thread-9lfiol

Conversation

@valzargaming

@valzargaming valzargaming commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Change

Last step of the Civ13 player activity plan. New staff message command <key>activity (Ambassador, Admin) for a server that heads a region group (region_group). It reads <group root>/player-activity-weekly.json, which the Civ13 host writes beside its activity database, and replies with totals only: active players today/week/month, new players this week, play sessions and median length, deaths, trips between lands and hours per region. No player names, research or recipe ids are in the file, and PlayerActivityTotals::clean drops anything unexpected, negative or non-numeric values and odd region names. Read-only; the bot never opens the database. Documented in docs/shard-group.md.

Verification

  • php tests/local/player-activity-totals.php: PASS (missing file, no group, broken JSON, oversized file, filtered fields and region names, message text)
  • php -l on the four touched PHP files: no syntax errors
  • php tests/local/heartbeat-roster.php: passed
  • Added both to the status-heartbeat workflow

Not run against a live bot or Discord.


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Ambassadors and Admins can use the activity command to view weekly player activity totals for a server’s region group, including active and new players, sessions, deaths, trips, and hours.
    • Reports show regional totals without player names.
  • Documentation
    • Added guidance on using the activity command and the information included in its reports.

…group

<key>activity (Ambassador, Admin) reads <group root>/player-activity-weekly.json,
which the Civ13 host writes beside its player activity database, and replies
with totals only (active and new players, sessions, deaths, trips, hours per
region). Unexpected fields, bad numbers and odd region names are dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WTP2USzsPRACAXT87D6UA
Copilot AI balanced review requested due to automatic review settings November 16, 2026 00:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The change adds a per-server activity command for Ambassadors and Admins. It reads weekly activity totals from the server’s region group, filters and formats the data, and replies with the totals or a read-failure reason.

Changes: Weekly Activity Command

Layer / File(s) Summary
Read, filter, and format totals
src/Civ13/PlayerActivityTotals.php, tests/local/player-activity-totals.php, .github/workflows/status-heartbeat.yml
Adds bounded JSON reads, validates and formats weekly totals, and tests missing, malformed, oversized, and filtered data. The heartbeat workflow checks PHP syntax and runs the local test.
Register and document the command
src/Civ13/GameServer.php, src/Civ13/MessageCommand/Commands/Civ13GameServerActivity.php, src/Civ13/MessageServiceManager.php, docs/shard-group.md
Exposes the configured region-group file, registers the activity command for Ambassador and Admin roles, and documents its source and displayed totals.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  actor Ambassador
  participant Civ13GameServerActivity
  participant GameServer
  participant PlayerActivityTotals
  participant RegionGroupFile
  participant WeeklyTotalsFile
  Ambassador->>Civ13GameServerActivity: Send activity command
  Civ13GameServerActivity->>GameServer: Get region-group file path
  Civ13GameServerActivity->>PlayerActivityTotals: Read totals using group file path
  PlayerActivityTotals->>RegionGroupFile: Read group configuration
  PlayerActivityTotals->>WeeklyTotalsFile: Read weekly totals
  PlayerActivityTotals-->>Civ13GameServerActivity: Return totals or read reason
  Civ13GameServerActivity-->>Ambassador: Reply with description or no-activity message
Loading
Merge Risk: Low · up to 9b0e2

The activity command could fail to reply if the totals file contains an all-digit region name. The impact is small and a one-line cast fixes it, so the change is mergeable with a quick follow-up.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copy link
Copy Markdown
Member Author

2026-11-16, head 9b0e273: adds <key>activity reading the Civ13 host's totals-only weekly file (written since Civ13/Civ13#5597). php tests/local/player-activity-totals.php passes locally; all PR workflows passed on this head, including Passive status heartbeat contracts on PHP 8.3-8.5 (Ubuntu and Windows). Not run against a live bot; it is not live until the bot is updated.


Generated by Claude Code

@valzargaming
valzargaming merged commit b13a176 into main Nov 16, 2026
50 of 51 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.

3 participants