Skip to content

Commit 7c8ad6e

Browse files
authored
Merge pull request os-checker#155 from os-checker/fix/package-info
fix(PkgInfo): handle undefined pkgs due to the JSON format change
2 parents 7fd67b4 + c56fe1d commit 7c8ad6e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

os-checks/pages/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ $fetch(docs_json_url).then(val => docs.value = val);
265265
266266
const summaryTable = computed<SummaryTable[]>(() => {
267267
const value = summaries.value.map(val => {
268-
return Object.entries(val.pkgs).map(([name, pkg]) => {
268+
return Object.entries(val.pkgs ?? {}).map(([name, pkg]) => {
269269
let testcases_color = null;
270270
if (pkg.testcases?.pkg_tests_count) {
271271
if (pkg.testcases?.failed === 0) {
@@ -457,7 +457,7 @@ watch(selectedPkg, val => {
457457
458458
const pkg = summaries.value
459459
.find(summary => summary.user === val.user && summary.repo === val.repo)
460-
?.pkgs[val.pkg];
460+
?.pkgs?.[val.pkg];
461461
462462
if (!pkg) { return; }
463463

os-checks/shared/info.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ import { type Col, Cols } from "./columns-select"
33
export type PkgInfo = {
44
user: string,
55
repo: string,
6-
pkgs: { [key: string]: Pkg }
6+
timestamp: TimeStamp,
7+
// good repo: pkgs and err are exclusive
8+
pkgs?: { [key: string]: Pkg },
9+
// compilation error
10+
err?: string,
11+
}
12+
13+
export type TimeStamp = {
14+
start: number,
15+
end: number,
716
}
817

918
export type Pkg = {
@@ -58,12 +67,12 @@ export type TestCase = {
5867
}
5968

6069
export function unique_field(summaries: PkgInfo[], cb: (_: Pkg) => string[]): string[] {
61-
const arr = summaries.map(s => Object.values(s.pkgs).map(pkg => cb(pkg).flat()).flat()).flat();
70+
const arr = summaries.map(s => Object.values(s.pkgs ?? {}).map(pkg => cb(pkg).flat()).flat()).flat();
6271
return [...new Set(arr)].sort();
6372
}
6473

6574
export function unique_field_bool(summaries: PkgInfo[], cb: (_: Pkg) => boolean): boolean {
66-
const arr = summaries.filter(s => Object.values(s.pkgs).filter(cb).length > 0)
75+
const arr = summaries.filter(s => Object.values(s.pkgs ?? {}).filter(cb).length > 0)
6776
return arr.length > 0;
6877
}
6978

os-checks/shared/testcases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function summariesToTestResult(pkg_info: PkgInfo[]): TestResult[] {
102102
let idx = 0;
103103

104104
for (const info of pkg_info) {
105-
for (const [pkg, value] of Object.entries(info.pkgs)) {
105+
for (const [pkg, value] of Object.entries(info.pkgs ?? {})) {
106106
for (const test of value.testcases?.tests || []) {
107107
for (const testcase of test.testcases) {
108108
result.push({

0 commit comments

Comments
 (0)