feat(labeling): ratios reset for labeling implemeneted
This commit is contained in:
@@ -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.",
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user