WFDASH-WEBAPP/scripts/verify-nss-revert.ts

39 lines
1.4 KiB
TypeScript
Raw Normal View History

import "./_env";
import { getAdminPocketBase } from "../src/lib/server/pocketbase-admin";
async function main() {
const pb = await getAdminPocketBase();
const rows = await pb.collection("stock_items").getList(1, 4, {
filter: 'location = "NSS Fasteners price list - hex nut DIN934 (Grade 8 + A2)"',
sort: "sku",
});
console.log("Sample rows after revert:\n");
for (const r of rows.items) {
console.log("SKU: " + r.sku);
console.log("name: " + JSON.stringify(r.name));
console.log("description:" + JSON.stringify(r.description));
console.log("notes: " + JSON.stringify(r.notes));
console.log("name == description? " + (r.name === r.description ? "YES ✓" : "NO ✗"));
console.log("");
}
const all = await pb.collection("stock_items").getFullList<{
name: string;
description: string;
}>({
filter: 'location = "NSS Fasteners price list - hex nut DIN934 (Grade 8 + A2)"',
fields: "name,description",
batch: 200,
});
const match = all.filter((r) => r.name === r.description).length;
console.log(`Rows where name == description: ${match}/${all.length}`);
const hasPosCode = await pb.collection("stock_items").getList(1, 1, {
filter: 'location = "NSS Fasteners price list - hex nut DIN934 (Grade 8 + A2)" && notes ~ "PosCode:"',
});
console.log(`Rows still containing "PosCode:" in notes: ${hasPosCode.totalItems}`);
}
main().catch((e) => {
console.error(e);
process.exit(1);
});