From ac88cdb0914a3f7483f2345bbfab33a3c0873855 Mon Sep 17 00:00:00 2001 From: 728 Date: Sun, 20 Nov 2022 12:50:47 +0800 Subject: [PATCH] json #25 --- cli/dbexport.zsh | 16 ++++++++++++++++ cli/dbimport.zsh | 16 ++++++++++++++++ cli/jsonfix.ts | 16 ++++++++++++++++ ismism.ts/src/typ.ts | 5 +++++ ismism.ts/ui/index.html | 2 +- 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 cli/jsonfix.ts diff --git a/cli/dbexport.zsh b/cli/dbexport.zsh index 55d14ea..08130a8 100644 --- a/cli/dbexport.zsh +++ b/cli/dbexport.zsh @@ -1 +1,17 @@ +echo mongoexport --jsonArray -d=ismism -c=user -o=json/user.json mongoexport --jsonArray -d=ismism -c=user -o=json/user.json + +echo mongoexport --jsonArray -d=ismism -c=soc -o=json/soc.json +mongoexport --jsonArray -d=ismism -c=soc -o=json/soc.json + +echo mongoexport --jsonArray -d=ismism -c=agenda -o=json/agenda.json +mongoexport --jsonArray -d=ismism -c=agenda -o=json/agenda.json + +echo mongoexport --jsonArray -d=ismism -c=work -o=json/work.json +mongoexport --jsonArray -d=ismism -c=work -o=json/work.json + +echo mongoexport --jsonArray -d=ismism -c=fund -o=json/fund.json +mongoexport --jsonArray -d=ismism -c=fund -o=json/fund.json + +echo mongoexport --jsonArray -d=ismism -c=dat -o=json/dat.json +mongoexport --jsonArray -d=ismism -c=dat -o=json/dat.json diff --git a/cli/dbimport.zsh b/cli/dbimport.zsh index fb504ee..7e422b5 100644 --- a/cli/dbimport.zsh +++ b/cli/dbimport.zsh @@ -1 +1,17 @@ +echo mongoimport --jsonArray -d=ismism -c=user --file=json/user.json mongoimport --jsonArray -d=ismism -c=user --file=json/user.json + +echo mongoimport --jsonArray -d=ismism -c=soc --file=json/soc.json +mongoimport --jsonArray -d=ismism -c=soc --file=json/soc.json + +echo mongoimport --jsonArray -d=ismism -c=agenda --file=json/agenda.json +mongoimport --jsonArray -d=ismism -c=agenda --file=json/agenda.json + +echo mongoimport --jsonArray -d=ismism -c=work --file=json/work.json +mongoimport --jsonArray -d=ismism -c=work --file=json/work.json + +echo mongoimport --jsonArray -d=ismism -c=fund --file=json/fund.json +mongoimport --jsonArray -d=ismism -c=fund --file=json/fund.json + +echo mongoimport --jsonArray -d=ismism -c=dat --file=json/dat.json +mongoimport --jsonArray -d=ismism -c=dat --file=json/dat.json diff --git a/cli/jsonfix.ts b/cli/jsonfix.ts new file mode 100644 index 0000000..83ad163 --- /dev/null +++ b/cli/jsonfix.ts @@ -0,0 +1,16 @@ +import { User, Work } from "../ismism.ts/src/typ.ts"; + +const user: User[] = JSON.parse(Deno.readTextFileSync("json/user.json")) +const work: Work[] = JSON.parse(Deno.readTextFileSync("json/work.json")) + +let n = 0 +for (const w of work) { + w._id = ++n + if (typeof w.uid === "number") continue + const u = user.find(u => u.name === w.uid as unknown as string) + console.log(`uid: ${w.uid} -> ${u?._id}`) + if (u) w.uid = u._id +} +console.log(`scanned ${n} work records`) + +Deno.writeTextFileSync("json/work-fix.json", JSON.stringify(work)) diff --git a/ismism.ts/src/typ.ts b/ismism.ts/src/typ.ts index 2fe7a34..d5d6a3e 100644 --- a/ismism.ts/src/typ.ts +++ b/ismism.ts/src/typ.ts @@ -58,6 +58,11 @@ export type Work = { op: "work", aid: number, msg: string +} | { + op: "video", + aid: number[], + title: string, + src: string, }) export type Fund = { diff --git a/ismism.ts/ui/index.html b/ismism.ts/ui/index.html index 61c22bd..10b3eac 100644 --- a/ismism.ts/ui/index.html +++ b/ismism.ts/ui/index.html @@ -830,7 +830,7 @@ nimg: 0, stat: { fund: 0, budget: 0, expense: 0, - detail: "https://docs.qq.com/sheet/DZWNvbXV3S0FDV0Nx?tab=zh23xc", + detail: "https://docs.qq.com/sheet/DZWNvbXV3S0FDV0Nx", progress: [ { goal: "厨房改造", pct: 5 }, { goal: "2022十一月营养餐食", pct: 0 },