Skip to content

Commit 15a2f5f

Browse files
authored
Merge pull request os-checker#121 from os-checker/feat/info-time
feat: info 页面 增加 Last Commit Time, Last Release Time 和 Last Realease Tarball Size 三列
2 parents 584f6b1 + 999e0f1 commit 15a2f5f

File tree

6 files changed

+40
-19
lines changed

6 files changed

+40
-19
lines changed

os-checks/pages/info.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<MultiSelect v-model="selected.kinds" display="chip" :options="kinds" filter :maxSelectedLabels="4"
2222
placeholder="Select Crate Kinds" />
2323

24-
<MultiSelect v-model="selected.columns" display="chip" :options="columns" :optionLabel="o => C.option(o)" filter
25-
:maxSelectedLabels="4" placeholder="Select Columns" />
24+
<MultiSelect v-model="selected.columns" display="chip" :options="columns" :optionLabel="o => C.option(o)"
25+
filter :maxSelectedLabels="4" placeholder="Select Columns" />
2626
</div>
2727

2828
<div>
@@ -48,6 +48,9 @@
4848

4949
<Column frozen sortable field="pkg" header="Package" style="min-width: 200px;" />
5050

51+
<Column v-if="C.display('last_commit_time')" sortable field="last_commit_time"
52+
:header="C.name('last_commit_time')" style="text-align: center;" />
53+
5154
<Column v-if="C.display('version')" sortable field="version" :header="C.name('version')"
5255
style="text-align: center;" />
5356

@@ -60,6 +63,12 @@
6063
</template>
6164
</Column>
6265

66+
<Column v-if="C.display('last_release_time')" sortable field="last_release_time"
67+
:header="C.name('last_release_time')" style="text-align: center; min-width: 120px;" />
68+
69+
<Column v-if="C.display('last_release_size')" sortable field="last_release_size"
70+
:header="C.name('last_release_size')" style="text-align: center" />
71+
6372
<Column v-if="C.display('diag_total_count')" sortable field="diag_total_count"
6473
:header="C.name('diag_total_count')" style="text-align: center;">
6574
<template #body="{ data }">
@@ -229,6 +238,7 @@
229238
<script setup lang="ts">
230239
import type { Pkg, PkgInfo, Test } from '~/shared/info';
231240
import { unique_field, unique_field_bool, InfoCols } from '~/shared/info';
241+
import { formatBytes } from '~/shared/columns-select';
232242
import { FilterMatchMode } from '@primevue/core/api';
233243
import type { DataTableSortMeta } from 'primevue/datatable';
234244
@@ -269,8 +279,11 @@ const summaryTable = computed<SummaryTable[]>(() => {
269279
user: val.user,
270280
repo: val.repo,
271281
pkg: name,
282+
last_commit_time: fmtDateTime(pkg.last_commit_time),
272283
version: pkg.version,
273284
release_count: pkg.release_count,
285+
last_release_time: fmtDateTime(pkg.last_release_time),
286+
last_release_size: pkg.last_release_size ? formatBytes(pkg.last_release_size): null,
274287
diag_total_count: pkg.diag_total_count,
275288
testcases: pkg.testcases?.pkg_tests_count ?? null,
276289
testcases_color,
@@ -325,7 +338,8 @@ type SummaryTable = {
325338
tests: number | null; examples: number | null; benches: number | null; keywords: string[] | null;
326339
authors: string[] | null; description: string; categories: string[] | null;
327340
documentation: string | null; readme: string | null; homepage: string | null; latest_doc: string | null;
328-
diag_total_count: number | null; release_count: number | null;
341+
diag_total_count: number | null; last_commit_time: string; release_count: number | null;
342+
last_release_size: string | null; last_release_time: string;
329343
};
330344
const data = ref<SummaryTable[]>([]);
331345
watch(summaryTable, (val) => data.value = val);

os-checks/pages/repos.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@
117117
<script setup lang="ts">
118118
import { FilterMatchMode } from '@primevue/core/api';
119119
import type { DataTableSortMeta } from 'primevue/datatable';
120-
import { formatBytes, RepoCols } from '~/shared/repos';
120+
import { RepoCols } from '~/shared/repos';
121+
import { formatBytes } from '~/shared/columns-select';
121122
import type { Output, Repo } from '~/shared/repos';
122123
123124
useHead({ title: 'Repositories Information' });

os-checks/shared/columns-select.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ export class Cols {
7373
}
7474
}
7575

76+
export function formatBytes(bytes: number, decimals = 0) {
77+
if (bytes === 0) { return '0 B'; }
78+
79+
const k = 1024; // 1KB = 1024 bytes
80+
const dm = decimals < 0 ? 0 : decimals; // 小数位数
81+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
82+
83+
const i = Math.floor(Math.log(bytes) / Math.log(k));
84+
85+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
86+
}
87+

os-checks/shared/info.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ export type Pkg = {
2222
homepage: string | null,
2323
keywords: string[],
2424
categories: string[]
25-
os_categories: string[],
2625
diag_total_count: number | null,
26+
last_commit_time: string,
2727
release_count: number | null,
28+
last_release_size: number | null,
29+
last_release_time: string | null,
2830
}
2931

3032
export type TestCases = {
@@ -64,12 +66,16 @@ export function unique_field_bool(summaries: PkgInfo[], cb: (_: Pkg) => boolean)
6466
// *************** Control which columns are displayed ***************
6567

6668
const defaultColumns = [
67-
"version", "release_count", "diag_total_count", "testcases", "documentation", "description"
69+
"last_commit_time", "version", "release_count", "diag_total_count", "testcases",
70+
"documentation", "description"
6871
];
6972

7073
const columns: { [key: string]: Col } = {
74+
last_commit_time: { display: false, name: "Last Commit", option: "Last Commit Time" },
7175
version: { display: false, name: "Version", option: "Version" },
7276
release_count: { display: false, name: "crates.io Releases", option: "crates.io Releases" },
77+
last_release_time: { display: false, name: "Last Release", option: "Last Release Time" },
78+
last_release_size: { display: false, name: "Release Size", option: "Last Release Size" },
7379
diag_total_count: { display: false, name: "Diag-nostics", option: "Diagnostics" },
7480
testcases: { display: false, name: "Test Cases", option: "Test Cases" },
7581

os-checks/shared/repos.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ export type Output = {
7171
contributors: Contributor[],
7272
}
7373

74-
export function formatBytes(bytes: number, decimals = 0) {
75-
if (bytes === 0) { return '0 B'; }
76-
77-
const k = 1024; // 1KB = 1024 bytes
78-
const dm = decimals < 0 ? 0 : decimals; // 小数位数
79-
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
80-
81-
const i = Math.floor(Math.log(bytes) / Math.log(k));
82-
83-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
84-
}
85-
8674
export type Repo = {
8775
idx: number,
8876
user: string,

os-checks/utils/fmt-date-time.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
export default function (utc: string | null) {
3-
if (!utc) { return "null"; }
3+
if (!utc) { return ""; }
44

55
const date = new Date(utc);
66
const year = date.getFullYear();

0 commit comments

Comments
 (0)