From 3e29a50c9c2ad662efecd5ceea2952f037292812 Mon Sep 17 00:00:00 2001 From: snomiao Date: Sun, 12 Jan 2025 12:33:43 +0000 Subject: [PATCH] fix(duplication): warnings ts-type warnings ts-type --- src/CRPulls.ts | 3 +++ src/updateCMNodesDuplicationWarnings.ts | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/CRPulls.ts b/src/CRPulls.ts index b4a0760..3e2f443 100644 --- a/src/CRPulls.ts +++ b/src/CRPulls.ts @@ -1,4 +1,7 @@ import type { CRPull } from "./CNRepos"; import { db } from "./db"; +/** + * @deprecated todo: utillize this collection @sno + */ export const CRPulls = db.collection("CRPulls"); diff --git a/src/updateCMNodesDuplicationWarnings.ts b/src/updateCMNodesDuplicationWarnings.ts index a352dea..e6c3177 100644 --- a/src/updateCMNodesDuplicationWarnings.ts +++ b/src/updateCMNodesDuplicationWarnings.ts @@ -1,19 +1,21 @@ -import { unary } from "lodash-es"; import pMap from "p-map"; -import { dissoc, filter, groupBy, map, prop, toPairs } from "rambda"; +import { filter, groupBy, map, prop, toPairs } from "rambda"; import YAML from "yaml"; import { CMNodes, type CMNode } from "./CMNodes"; import { notifySlack } from "./slack/notifySlack"; export async function updateCMNodesDuplicationWarnings(nodes: CMNode[]) { console.log("CMNodes checking duplicates"); + const idGroups = groupBy((e) => e.id, nodes); + const titleGroups = groupBy((e) => e.title, nodes); + const referenceGroups = groupBy((e) => e.reference, nodes); // prettier-ignore const dups = { - ID: filter((e: typeof nodes) => e.length > 1, groupBy((e) => e.id, nodes)), - TITLE: filter((e: typeof nodes) => e.length > 1, groupBy((e) => e.title, nodes)), - REFERENCE: filter((e: typeof nodes) => e.length > 1, groupBy((e) => e.reference, nodes)), + ID: filter((e?: CMNode[]) => (e?.length??0) > 1, idGroups), + TITLE: filter((e?: CMNode[]) => (e?.length??0) > 1, titleGroups), + REFERENCE: filter((e?: CMNode[]) => (e?.length??0) > 1, referenceGroups), }; - const dupsSummary = JSON.stringify(map((x) => map((x) => x.length, x), dups)); + const dupsSummary = JSON.stringify(map((x) => map((x) => x?.length ?? 0, x), dups)); await notifySlack( `[WARN] CMNodes duplicates: ${dupsSummary}\nSolve them in https://github.com/ltdrdata/ComfyUI-Manager/blob/main/custom-node-list.json`, ); @@ -24,8 +26,11 @@ export async function updateCMNodesDuplicationWarnings(nodes: CMNode[]) { await pMap( toPairs(nodes), async ([key, nodesRaw]) => { - const nodes = nodesRaw.map(unary(dissoc("hash"))); - const hashes = nodesRaw.map(prop("hash")); + const nodes = nodesRaw?.map((nodeRaw) => { + const { hash, ...node } = { ...nodeRaw }; + return node; + }); + const hashes = nodesRaw?.map(prop("hash")); // check sent const someDuplicateSent = await CMNodes.findOne({ hash: { $in: hashes },