Skip to content

Commit

Permalink
Fix killswitches notifications (#1085)
Browse files Browse the repository at this point in the history
* Update names
* fix onlyDisabledFeatures
  • Loading branch information
atuchin-m authored Jun 11, 2024
1 parent 8dfea9d commit 08c9efd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/core/study_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export enum StudyPriority {
STABLE_MIN,
STABLE_50,
STABLE_ALL,
STABLE_ALL_EMERGENCY,
STABLE_EMERGENCY_KILL_SWITCH,
}

export class StudyFilter {
Expand Down Expand Up @@ -149,7 +149,7 @@ export function priorityToText(p: StudyPriority): string {
return 'stable-50%';
case StudyPriority.STABLE_ALL:
return 'stable-100%';
case StudyPriority.STABLE_ALL_EMERGENCY:
case StudyPriority.STABLE_EMERGENCY_KILL_SWITCH:
return 'stable-emergency-kill-switch';
}
return '';
Expand All @@ -159,12 +159,12 @@ export class StudyDetails {
endedByEndDate = false; // now() < end_date
endedByMaxVersion = false; // max_version < current_stable
isBlocklisted = false; // matches to config.js blocklists
isEmergency = false; // matches a kill switch signature
isKillSwitch = false; // matches a kill switch signature
hasNoSupportedPlatform = false; // doesn't have any brave-supported platform
isBadStudyFormat = false; // a bad protobuf item
isArchived = false; // max_version <= 100.*
hasLimitedFilter = false; // the filter limits the audience significantly.
onlyDisabledFeatures = false;
onlyDisabledFeatures = true;

totalWeight = 0;
totalNonDefaultGroupsWeight = 0;
Expand Down Expand Up @@ -218,7 +218,7 @@ export class StudyDetails {
this.hasLimitedFilter ||=
filter?.google_group != null && filter?.google_group.length !== 0;

this.isEmergency = isKillSwitch(study.name);
this.isKillSwitch = isKillSwitch(study.name);
for (const e of experiment) {
const enableFeatures = e.feature_association?.enable_feature;
const disabledFeatures = e.feature_association?.disable_feature;
Expand All @@ -229,9 +229,9 @@ export class StudyDetails {
disabledFeatures != null &&
disabledFeatures.some((n) => isFeatureBlocklisted(n));

this.isEmergency ||= e.probability_weight > 0 && isKillSwitch(e.name);
this.isKillSwitch ||= e.probability_weight > 0 && isKillSwitch(e.name);

this.onlyDisabledFeatures ||=
this.onlyDisabledFeatures &&=
e.probability_weight === 0 ||
e.feature_association?.enable_feature == null ||
e.feature_association?.enable_feature.length === 0;
Expand Down Expand Up @@ -277,8 +277,8 @@ export class StudyDetails {
this.maxNonDefaultWeight > this.totalWeight / 2 &&
!this.hasLimitedFilter
) {
return this.isEmergency
? StudyPriority.STABLE_ALL_EMERGENCY
return this.isKillSwitch
? StudyPriority.STABLE_EMERGENCY_KILL_SWITCH
: StudyPriority.STABLE_ALL;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SummaryItem {

getChangePriority(): StudyPriority {
if (this.isKillSwitchImportantUpdate()) {
return StudyPriority.STABLE_ALL_EMERGENCY;
return StudyPriority.STABLE_EMERGENCY_KILL_SWITCH;
}
return Math.max(this.oldPriority, this.newPriority);
}
Expand All @@ -54,7 +54,7 @@ class SummaryItem {
if (this.hasOnlyDisabledFeatures) return true;
}
return (
this.newPriority === StudyPriority.STABLE_ALL_EMERGENCY &&
this.newPriority === StudyPriority.STABLE_EMERGENCY_KILL_SWITCH &&
this.action !== ItemAction.Down &&
this.action !== ItemAction.RemovedOrOutdated
);
Expand Down

0 comments on commit 08c9efd

Please sign in to comment.