Skip to content

Commit

Permalink
Set flag edit based on flag source combination
Browse files Browse the repository at this point in the history
  • Loading branch information
hvangeffen committed Apr 26, 2024
1 parent 75fee95 commit 3c4750e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/lib/table/tableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ export function createTableData(
...event,
}
if (event.flag !== undefined && store.flags !== undefined) {
const flag = store.flags[event.flag]
const flag = store.flags.find((f) => f.flag === event.flag)
if (flag !== undefined) {
eventResult.flagOrigin = flag.source
eventResult.flagQuality = flag.quality
eventResult.flagEdit = qualityToFlagEdit(flag.quality)
eventResult.flagEdit = qualityToFlagEdit(
event.flag,
event.flagSource,
flag?.quality,
)
}
}
pointers[j]++
Expand All @@ -92,17 +96,26 @@ export function createTableData(
* @returns {TimeSeriesEvent['flagEdit']} - The flag edit string.
*/
function qualityToFlagEdit(
quality: TimeSeriesFlag['quality'],
flag: TimeSeriesData['flag'],
source: TimeSeriesData['flagSource'],
quality?: TimeSeriesFlag['quality'],
): TimeSeriesEvent['flagEdit'] {
if (flag === '6' && source === 'SFP') {
return 'Persistent Unreliable'
}

// @ts-expect-error: remove once pi-requests is updated
if (flag === '14') {
return 'Accumulation Reset'
}

switch (quality) {
case 'RELIABLE':
return 'Reliable'
case 'DOUBTFUL':
return 'Doubtful'
case 'UNRELIABLE':
return 'Unreliable'
default:
return undefined
}
}

Expand Down

0 comments on commit 3c4750e

Please sign in to comment.