Skip to content

Commit fe09a28

Browse files
committed
fix(workflows): update fields with null value
ref: os-checker/plugin-github-api#2
1 parent c5a25e9 commit fe09a28

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

os-checks/pages/workflows.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ const runColumns = [
241241
// { field: "updated_at", header: "Updated" },
242242
]
243243
244-
function fmtDateTime(utc: string) {
244+
function fmtDateTime(utc: string | null) {
245+
if (!utc) { return "null"; }
246+
245247
const date = new Date(utc);
246248
const year = date.getFullYear();
247249
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,所以加1
@@ -277,7 +279,7 @@ const runSelected = computed(() => {
277279
278280
// https://github.com/os-checker/database/blob/debug/plugin/github-api/workflows/Byte-OS/polyhal.json
279281
280-
function icon(status: string, conclusion: string) {
282+
function icon(status: string, conclusion: string | null) {
281283
if (status === "completed") {
282284
switch (conclusion) {
283285
case "success": return { icon: "pi pi-check", color: "#607D8B" };
@@ -348,7 +350,7 @@ const jobsInfo = computed(() => {
348350
const j = val.workflows[workflow_idx].jobs;
349351
const jj = val.workflows[workflow_idx].jobs.jobs;
350352
351-
const is_success = (s: string) => s === "success" || s === "skipped";
353+
const is_success = (s: string | null) => s === "success" || s === "skipped";
352354
353355
const total_jobs = j.total_count;
354356
const completed_jobs = jj.filter(job => job.status === "completed").length;

os-checks/shared/workflows.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export type Workflow = {
2020
html_url: string,
2121
event: string,
2222
status: string,
23-
conclusion: string,
23+
// conclusion is null when status is "in_progress"
24+
conclusion: string | null,
2425
run_attempt: number,
2526
run_started_at: string,
2627
created_at: string,
@@ -48,10 +49,11 @@ export type Job = {
4849
workflow_name: string,
4950
html_url: string,
5051
status: string,
51-
conclusion: string,
52+
conclusion: string | null,
5253
created_at: string,
5354
started_at: string,
54-
completed_at: number,
55+
// completed_at is null when status is "in_progress"
56+
completed_at: number | null,
5557
duration_sec: string,
5658
steps: Step[],
5759
id: number,
@@ -60,10 +62,11 @@ export type Job = {
6062
export type Step = {
6163
name: string,
6264
status: string,
63-
conclusion: string,
65+
conclusion: string | null,
6466
number: number,
65-
started_at: string,
66-
completed_at: string,
67+
// cancel or in progress can make these null
68+
started_at: string | null,
69+
completed_at: string | null,
6770
duration_sec: number,
6871
}
6972

@@ -89,7 +92,7 @@ export type LastWorkflow = {
8992
workflows: Workflow[],
9093
}
9194

92-
export function summary_to_workflows(summary: Summary ): Workflows {
95+
export function summary_to_workflows(summary: Summary): Workflows {
9396
return {
9497
user: summary.user,
9598
repo: summary.repo,

0 commit comments

Comments
 (0)