feat(labeling): ratios reset for labeling implemeneted

This commit is contained in:
2025-07-14 12:37:38 -05:00
parent a7f8e39bac
commit 61f0b7f06b
11 changed files with 340 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { sql } from "drizzle-orm";
import { eq, sql } from "drizzle-orm";
import { db } from "../../../../../database/dbclient.js";
import { labelRatio } from "../../../../../database/schema/ratios.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
@@ -51,3 +51,34 @@ export const manualLabelCreated = async () => {
);
}
};
export const resetLabelRatio = async () => {
const { error } = await tryCatch(
db
.update(labelRatio)
.set({
name: sql`'label-' || (SELECT count(*) FROM ${labelRatio})`,
lastReset: sql`NOW()`,
})
.where(eq(labelRatio.name, "label"))
);
if (error) {
console.log(error);
createLog(
"error",
"labeling",
"ocp",
"There was an error resetting Label Ratio"
);
return {
success: false,
message: "There was an issue resetting the label data.",
};
}
return {
success: true,
message: "Label Ratio has been reset.",
};
};