13 lines
1.1 KiB
TypeScript
13 lines
1.1 KiB
TypeScript
|
|
import PocketBase from "pocketbase";
|
||
|
|
const pb = new PocketBase(process.env.NEXT_PUBLIC_POCKETBASE_URL!);
|
||
|
|
await pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL!, process.env.POCKETBASE_ADMIN_PASSWORD!);
|
||
|
|
const sleep=(ms:number)=>new Promise(r=>setTimeout(r,ms));
|
||
|
|
let w=0; while(w<660){ if((await pb.collection("dn_pipeline_locks").getFullList()).length===0) break; await sleep(15000); w+=15; }
|
||
|
|
console.log(w>=660 ? "STILL LOCKED" : `lock released after ~${w}s`);
|
||
|
|
const n = await pb.collection("DN_BATCH_NOTES").getFullList({ filter:'batch = "3ce6tdvkinny9is"', fields:"delivery_note_number,pages,checks" });
|
||
|
|
const failing = n.filter((x:any)=>(x.checks as any[]).some(c=>c.passed!==true));
|
||
|
|
console.log(`PASSED: ${n.length-failing.length} / ${n.length}`);
|
||
|
|
const g: Record<string,string[]> = {};
|
||
|
|
for (const f of failing) for (const c of (f.checks as any[]).filter(c=>c.passed!==true)) (g[c.reason]=g[c.reason]??[]).push(`p${JSON.stringify(f.pages)} ${f.delivery_note_number}`);
|
||
|
|
for (const [reason, who] of Object.entries(g).sort((a,b)=>b[1].length-a[1].length)) console.log(` [${who.length}] ${reason}\n ${who.join(", ")}`);
|