Skip to content

Commit

Permalink
fix(duplication): warnings ts-type
Browse files Browse the repository at this point in the history
warnings ts-type
  • Loading branch information
snomiao committed Jan 12, 2025
1 parent 09a9c67 commit 3e29a50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/CRPulls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { CRPull } from "./CNRepos";
import { db } from "./db";

/**
* @deprecated todo: utillize this collection @sno
*/
export const CRPulls = db.collection<CRPull>("CRPulls");
21 changes: 13 additions & 8 deletions src/updateCMNodesDuplicationWarnings.ts
Original file line number Diff line number Diff line change
@@ -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`,
);
Expand All @@ -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 },
Expand Down

0 comments on commit 3e29a50

Please sign in to comment.