You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Player Counter: make query rate limit configurable - #180
This PR makes the rate limit for the Player Counter query endpoints configurable in the plugin settings. It was hardcoded to 2 requests per minute per server.
The reason for this change is that I am relying on this plugin for retrieving player lists from my own hosted servers, to display on my website and Discord server. Since they're my own, I would like to query them every 15 seconds, which exceeded the original rate limits.
What's new:
New setting "Query rate limit" (integer, minimum 0), saved as PLAYER_COUNTER_QUERY_RATE_LIMIT
Default stays at 2, so existing installs behave the same
0 disables the plugin's limit. The panel-wide client API rate limit however still applies
Negative values set directly in .env are treated as 1
The limit still covers /api/client/servers/{uuid}/query and /query/players with one shared bucket per server. My use case has no interest in splitting these up into separate buckets, but could be a logical next step.
What has been tested
I've tested the following things to make sure it works:
Settings field loads with the current value and saves to .env
With the limit at 5: five requests pass, the sixth returns 429
Without the env key: two requests pass, the third returns 429
PLAYER_COUNTER_QUERY_RATE_LIMIT=0: 10 requests in a row without a 429
PLAYER_COUNTER_QUERY_RATE_LIMIT=-3 results in a limit of 1
Pint and PHPStan pass
AI usage
The German and Russian translations of the three new strings were generated with AI (Claude Fable 5.2) to make sure the translations are more contextual than e.g. Google Translate. The translations have not been reviewed by a native speaker however. Corrections are welcome, or I can drop them and leave only the English strings.
Summary by CodeRabbit
New Features
Added a configurable per-server rate limit for query requests, set to two requests per minute by default. Both query endpoints share this limit.
You can adjust the limit in the player counter settings. Set it to 0 to disable the per-server limit; the panel-wide API limit continues to apply.
Settings labels and guidance are available in English, German, and Russian.
No actionable comments were generated in the recent review.
Walkthrough
The player-counter plugin now exposes a configurable per-server query rate limit. The setting defaults to 2 requests per minute. A value of 0 disables this limiter, while the panel-wide Client API limit continues to apply.
Changes: Query rate limit
Layer / File(s)
Summary
Configure the query rate limit player-counter/config/player-counter.php, player-counter/src/PlayerCounterPlugin.php, player-counter/lang/*/query.php
The settings form adds a required integer field with a minimum of 0 and saves its value to PLAYER_COUNTER_QUERY_API_RATE_LIMIT. Configuration reads this value and defaults to 2. English, German, and Russian translations describe the setting.
Apply the per-server query limit player-counter/src/Providers/PlayerCounterRoutesProvider.php
The limiter uses the configured value for requests keyed by server UUID. A value of 0 disables this limiter; other values allow at least one request per minute.
This adds a configurable per-server query rate limit that defaults to the previous value of 2 per minute. I found no concrete defect in the change. The PR description names a different environment key than the code uses, so documentation should use PLAYER_COUNTER_QUERY_API_RATE_LIMIT. The German and Russian translations are unreviewed.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the Player Counter query rate limit becomes configurable. The changeset adds a query_api_rate_limit setting, its environment variable, a settings field, translations…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the Player Counter query rate limit becomes configurable. The changeset adds a query_api_rate_limit setting, its environment variable, a settings field, translations, and a route provider change that reads the setting. The title is accurate and specific. The PR objectives name the environment key as PLAYER_COUNTER_QUERY_RATE_LIMIT, while the code summary uses PLAYER_COUNTER_QUERY_API_RATE_LIMIT. That naming mismatch does not affect the title check.
Finishing Touches
Generate unit tests (beta)
Create a new PR
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.
A rabbit checks the minute rate, Two requests pass through the gate. Set zero, this limit rests, The panel-wide rule still does its tests. New labels help each setting show, While server-keyed requests flow.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: b660b9cb-221c-441e-8c7b-1dcc1ec5781a
Commits
Reviewing files that changed from the base of the PR and between ad8778e and 06d724d.
Files skipped from review as they are similar to previous changes: 2
player-counter/lang/de/query.php
player-counter/lang/ru/query.php
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
Recent review details
Context from checks skipped due to timeout: 1
GitHub Check: CodeRabbit
Additional comments: 2
player-counter/config/player-counter.php: 1
5-5: Data Integrity & Integration
The comment asks whether the PR description's key must remain supported. The later commit message records a rename to query_api_rate_limit, and the configuration reads the key it implies. The mismatch lies in the PR description, which is a superseded draft reference. No repository contract or existing public setting requires the old key. The question concerns maintainer intent, not a demonstrated defect in the changed code. The stated check cannot be turned into a code change from the supplied evidence.
player-counter/src/PlayerCounterPlugin.php: 1
62-62: Functional Correctness
The saved value takes effect on the next request in the normal save workflow. The cached-configuration scenario does not occur through this path.
@Boy132 as requested, I have changed the setting name.
I've renamed it to query_api_rate_limit (env: PLAYER_COUNTER_QUERY_API_RATE_LIMIT) and changed the label to "Query API rate limit". I went with this order so "rate limit" stays together, but I'm happy to switch to query_rate_api_limit if you prefer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature Description
This PR makes the rate limit for the Player Counter query endpoints configurable in the plugin settings. It was hardcoded to 2 requests per minute per server.
The reason for this change is that I am relying on this plugin for retrieving player lists from my own hosted servers, to display on my website and Discord server. Since they're my own, I would like to query them every 15 seconds, which exceeded the original rate limits.
What's new:
PLAYER_COUNTER_QUERY_RATE_LIMIT0disables the plugin's limit. The panel-wide client API rate limit however still applies.envare treated as 1The limit still covers
/api/client/servers/{uuid}/queryand/query/playerswith one shared bucket per server. My use case has no interest in splitting these up into separate buckets, but could be a logical next step.What has been tested
I've tested the following things to make sure it works:
.envPLAYER_COUNTER_QUERY_RATE_LIMIT=0: 10 requests in a row without a 429PLAYER_COUNTER_QUERY_RATE_LIMIT=-3results in a limit of 1AI usage
The German and Russian translations of the three new strings were generated with AI (Claude Fable 5.2) to make sure the translations are more contextual than e.g. Google Translate. The translations have not been reviewed by a native speaker however. Corrections are welcome, or I can drop them and leave only the English strings.
Summary by CodeRabbit
0to disable the per-server limit; the panel-wide API limit continues to apply.