Skip to content

Commit 7a4247c

Browse files
committed
chore(info): define unique_field; description is string not string[]
1 parent 8529553 commit 7a4247c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

os-checks/pages/info.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115

116116
<script setup lang="ts">
117117
import type { Pkg, PkgInfo, Test } from '~/shared/info';
118+
import { unique_field } from '~/shared/info';
118119
import { FilterMatchMode } from '@primevue/core/api';
119120
120121
// interactive filter/search inputs
@@ -179,13 +180,13 @@ const summaryTable = computed<SummaryTable[]>(() => {
179180
});
180181
});
181182
182-
type SummaryTable = { idx: number; user: string; repo: string; pkg: string; version: string; dependencies: number | null; testcases: number | null; tests: number | null; examples: number | null; benches: number | null; author: string[] | null; description: string[]; categories: string[] | null; os_categories: string[] | null; };
183+
type SummaryTable = { idx: number; user: string; repo: string; pkg: string; version: string; dependencies: number | null; testcases: number | null; tests: number | null; examples: number | null; benches: number | null; author: string[] | null; description: string; categories: string[] | null; os_categories: string[] | null; };
183184
const data = ref<SummaryTable[]>([]);
184185
watch(summaryTable, (val) => data.value = val);
185186
186-
const categories = computed(() => [...new Set(summaryTable.value.map(val => val.categories).flat().filter(c => c))].sort());
187-
const os_categories = computed(() => [...new Set(summaryTable.value.map(val => val.os_categories).flat().filter(c => c))].sort());
188-
const authors = computed(() => [...new Set(summaryTable.value.map(val => val.author).flat().filter(c => c))].sort());
187+
const categories = computed(() => unique_field(summaries.value, pkg => pkg.categories));
188+
const os_categories = computed(() => unique_field(summaries.value, pkg => pkg.os_categories));
189+
const authors = computed(() => unique_field(summaries.value, pkg => pkg.author));
189190
const selectedCategories = ref<string[]>([]);
190191
const selectedOSCategories = ref<string[]>([]);
191192
const selectedAuthors = ref<string[]>([]);

os-checks/shared/info.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type Pkg = {
1414
examples: number,
1515
benches: number,
1616
author: string[]
17-
description: string[],
17+
description: string,
1818
categories: string[]
1919
os_categories: string[],
2020
}
@@ -32,3 +32,8 @@ export type Test = {
3232
binary_path: string,
3333
testcases: string[]
3434
}
35+
36+
export function unique_field(summaries: PkgInfo[], cb: (_: Pkg) => string[]): string[] {
37+
const arr = summaries.map(s => Object.values(s.pkgs).map(pkg => cb(pkg).flat()).flat()).flat();
38+
return [...new Set(arr)].sort();
39+
}

0 commit comments

Comments
 (0)