Skip to content

Commit c21fd8b

Browse files
committed
fix: apply coderabbit suggestion
1 parent 5d13e29 commit c21fd8b

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

app/components/Package/TrendsChart.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,18 +1035,23 @@ const chartData = computed<{
10351035
10361036
const dataset: VueUiXyDatasetItem[] = names.map(pkg => {
10371037
const points = pointsByPackage.get(pkg) ?? []
1038-
const map = new Map<number, number>()
1039-
for (const p of points) map.set(p.timestamp, p.value)
1038+
const valueByTimestamp = new Map<number, number>()
1039+
const anomalyTimestamps = new Set<number>()
1040+
for (const p of points) {
1041+
valueByTimestamp.set(p.timestamp, p.value)
1042+
if (p.hasAnomaly) anomalyTimestamps.add(p.timestamp)
1043+
}
10401044
1041-
const series = dates.map(t => map.get(t) ?? 0)
1045+
const series = dates.map(t => valueByTimestamp.get(t) ?? 0)
1046+
const dashIndices = dates
1047+
.map((t, index) => (anomalyTimestamps.has(t) ? index : -1))
1048+
.filter(index => index !== -1)
10421049
10431050
const item: VueUiXyDatasetItem = {
10441051
name: pkg,
10451052
type: 'line',
10461053
series,
1047-
dashIndices: points
1048-
.map((item, index) => (item.hasAnomaly ? index : -1))
1049-
.filter(index => index !== -1),
1054+
dashIndices,
10501055
} as VueUiXyDatasetItem
10511056
10521057
if (isListedFramework(pkg)) {

0 commit comments

Comments
 (0)