File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 115115
116116<script setup lang="ts">
117117import type { Pkg , PkgInfo , Test } from ' ~/shared/info' ;
118+ import { unique_field } from ' ~/shared/info' ;
118119import { 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 ; };
183184const data = ref <SummaryTable []>([]);
184185watch (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 ));
189190const selectedCategories = ref <string []>([]);
190191const selectedOSCategories = ref <string []>([]);
191192const selectedAuthors = ref <string []>([]);
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments