Skip to content

Commit

Permalink
Notify about killswitch updates (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
atuchin-m authored Nov 8, 2023
1 parent 0f21959 commit 40dd525
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/core/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ class SummaryItem {
hasBadStudies: boolean;

getChangePriority(): StudyPriority {
if (this.isNewKillSwitch()) return StudyPriority.STABLE_ALL_EMERGENCY;
if (this.isKillSwitchImportantUpdate()) {
return StudyPriority.STABLE_ALL_EMERGENCY;
}
return Math.max(this.oldPriority, this.newPriority);
}

isNewKillSwitch(): boolean {
isKillSwitchImportantUpdate(): boolean {
if (
this.newPriority === StudyPriority.STABLE_ALL &&
this.oldPriority < StudyPriority.STABLE_MIN &&
Expand All @@ -53,12 +55,13 @@ class SummaryItem {
}
return (
this.newPriority === StudyPriority.STABLE_ALL_EMERGENCY &&
(this.action === ItemAction.Up || this.action === ItemAction.New)
this.action !== ItemAction.Down &&
this.action !== ItemAction.RemovedOrOutdated
);
}

actionToText(): string {
if (this.isNewKillSwitch()) return ':warning:';
if (this.isKillSwitchImportantUpdate()) return ':warning:';

switch (this.action) {
case ItemAction.New:
Expand Down Expand Up @@ -270,7 +273,7 @@ export function summaryToJson(
newGitSha1?: string,
): string | undefined {
const output = new MrkdwnMessage();
let hasNewKillSwitches = false;
let hasKillSwitchImportantUpdate = false;
let hasBadStudies = false;

// From the highest to the lowest priority:
Expand All @@ -289,7 +292,7 @@ export function summaryToJson(
);
itemList.sort((a, b) => a.action - b.action);
for (const e of itemList) {
hasNewKillSwitches ||= e.isNewKillSwitch();
hasKillSwitchImportantUpdate ||= e.isKillSwitchImportantUpdate();
hasBadStudies ||= e.hasBadStudies;
const block = new TextBlock(e.actionToText());
block.addLink(url_utils.getGriffinUiUrl(e.studyName), e.studyName);
Expand Down Expand Up @@ -325,10 +328,10 @@ export function summaryToJson(
}
if (output.toString() === '') return undefined;

if (hasNewKillSwitches) {
if (hasKillSwitchImportantUpdate) {
output.addBlockToTop(
new TextBlock(
'New kill switches detected, cc ' +
'Kill switches changes detected, cc ' +
config.killSwitchNotificationIds.map((i) => `<@${i}>`).join(),
),
);
Expand Down

0 comments on commit 40dd525

Please sign in to comment.