Skip to content

Commit 94b4d33

Browse files
authored
Fixed problem acknowledging alerts when alerts had non-unique ID codes. (#92)
1 parent ff62b0e commit 94b4d33

12 files changed

Lines changed: 28 additions & 21 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.5.2
2+
3+
* Fixed problem acknowledging alerts when alerts had non-unique ID codes.
4+
15
## 3.5.1-do
26

37
* Documentation-only update: no code changes or bug fixes, just more clarity on the installation process.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aw-clock",
3-
"version": "3.5.1-do",
3+
"version": "3.5.2",
44
"license": "MIT",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"scripts": {

sass/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sass/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aw-clock-sass",
3-
"version": "3.5.1-do",
3+
"version": "3.5.2",
44
"description": "SASS builder for aw-clock",
55
"keywords": [
66
"sass"

server/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aw-clock-server",
3-
"version": "3.5.1-do",
3+
"version": "3.5.2",
44
"license": "MIT",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"private": true,

server/src/awcs-util.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Request, Response } from 'express';
22
import { acos, cos_deg, PI, sin_deg } from '@tubular/math';
33
import { ErrorMode, monitorProcess, spawn } from './process-util';
4-
import { ForecastData } from './shared-types';
4+
import { Alert, ForecastData } from './shared-types';
55
import { isNumber, isString } from '@tubular/util';
66
import compareVersions, { CompareOperator } from 'compare-versions';
77

@@ -227,6 +227,12 @@ export function checksum53(s: string, seed = 0): string {
227227
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).toUpperCase().padStart(14, '0');
228228
}
229229

230+
export function setAlertId(alert: Alert): Alert {
231+
alert.id = checksum53(`${alert.title}\t${alert.description}\t${alert.severity}`);
232+
233+
return alert;
234+
}
235+
230236
export function safeCompareVersions(firstVersion: string, secondVersion: string, defValue?: number): number;
231237
export function safeCompareVersions(firstVersion: string, secondVersion: string, operator?: CompareOperator, defValue?: boolean): boolean;
232238
export function safeCompareVersions(firstVersion: string, secondVersion: string,

server/src/shared-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const AlertKeys = ['description', 'expires', 'id', 'severity', 'title', '
8787
export interface Alert {
8888
description: string;
8989
expires: number; // See CommonConditions
90-
id: string;
90+
id?: string;
9191
severity: 'info' | 'advisory' | 'watch' | 'warning';
9292
time: number; // See CommonConditions
9393
title: string;

server/src/visual-crossing-forecast.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
Alert, CommonConditions, CommonConditionsKeys, CurrentConditions, CurrentConditionsKeys, DailyConditions, DailyConditionsKeys,
77
DailySummaryConditions, ForecastData, ForecastDataKeys, HourlyConditions, PressureTrend
88
} from './shared-types';
9-
import { alertCleanUp, checkForecastIntegrity, checksum53, filterError, hpaToInHg } from './awcs-util';
9+
import { alertCleanUp, checkForecastIntegrity, filterError, hpaToInHg, setAlertId } from './awcs-util';
1010
import { clone, isNumber, push } from '@tubular/util';
1111
import { floor } from '@tubular/math';
1212

@@ -304,10 +304,9 @@ function convertAlerts(vcAlerts: VCAlert[]): Alert[] {
304304

305305
alert.title = vcAlert.headline;
306306
alert.description = alertCleanUp(vcAlert.description);
307-
alert.id = checksum53(vcAlert.id);
308307
alert.time = nullIfError(floor(new Date(vcAlert.onset).getTime() / 1000));
309308
alert.expires = nullIfError(floor(new Date(vcAlert.ends).getTime() / 1000));
310309

311-
return alert;
310+
return setAlertId(alert);
312311
});
313312
}

0 commit comments

Comments
 (0)