Skip to content

Commit

Permalink
refactor(server): clean up code for restricted rules test
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
fabrichter and coderabbitai[bot] authored Oct 25, 2024
1 parent f059ec4 commit 8ab8678
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,16 @@ public RuleMatch[] match(AnalyzedSentence sentence) throws IOException {
}
List<String> enabledRules = getEnabledRuleIds(params);

if ((onlyTestUsers.contains(params.getOrDefault("username", "")) ||
(abTest != null && abTest.contains("only"))) &&
onlyTestLanguages.contains(lang.getShortCodeWithCountryAndVariant()) &&
onlyTestClients.contains(agent)) {
private boolean shouldApplyTestRules(Map<String, String> params, String agent, Language lang, List<String> abTest) {
String username = params.getOrDefault("username", "");
return (onlyTestUsers.contains(username) || (abTest != null && abTest.contains("only"))) &&
onlyTestLanguages.contains(lang.getShortCodeWithCountryAndVariant()) &&
onlyTestClients.contains(agent);
}

if (shouldApplyTestRules(params, agent, lang, abTest)) {
log.debug("Applying test rules for user: {}, language: {}, client: {}",
params.getOrDefault("username", ""), lang.getShortCodeWithCountryAndVariant(), agent);
useEnabledOnly = true;
enabledRules = onlyTestRules;
}
Expand Down

0 comments on commit 8ab8678

Please sign in to comment.