feat(labelratio): new feature to monitor label ratio from auto and manual
this was designed more for dayton but could be used for all plants
This commit is contained in:
23
server/services/ocp/controller/labeling/getLabelRatio.ts
Normal file
23
server/services/ocp/controller/labeling/getLabelRatio.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { labelRatio } from "../../../../../database/schema/ratios.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
export const getLabelRatio = async () => {
|
||||
const { data: labelInfo, error: labelError } = await tryCatch(
|
||||
db.select().from(labelRatio)
|
||||
);
|
||||
|
||||
if (labelError) {
|
||||
return {
|
||||
success: false,
|
||||
message: "There was an error getting the labels",
|
||||
data: [labelError],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Current labels order by upd_Date.",
|
||||
count: labelInfo.length,
|
||||
data: labelInfo,
|
||||
};
|
||||
};
|
||||
53
server/services/ocp/controller/labeling/labelRatio.ts
Normal file
53
server/services/ocp/controller/labeling/labelRatio.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { labelRatio } from "../../../../../database/schema/ratios.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
|
||||
export const autoLabelCreated = async () => {
|
||||
const { error } = await tryCatch(
|
||||
db
|
||||
.insert(labelRatio)
|
||||
.values({
|
||||
name: "label",
|
||||
autoLabel: 1,
|
||||
})
|
||||
.onConflictDoUpdate({
|
||||
target: labelRatio.name,
|
||||
set: { autoLabel: sql`${labelRatio.autoLabel} + 1` },
|
||||
})
|
||||
);
|
||||
|
||||
if (error) {
|
||||
createLog(
|
||||
"error",
|
||||
"labeling",
|
||||
"ocp",
|
||||
"There was an error updating auto label ratio"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const manualLabelCreated = async () => {
|
||||
const { error } = await tryCatch(
|
||||
db
|
||||
.insert(labelRatio)
|
||||
.values({
|
||||
name: "label",
|
||||
manualLabel: 1,
|
||||
})
|
||||
.onConflictDoUpdate({
|
||||
target: labelRatio.name,
|
||||
set: { manualLabel: sql`${labelRatio.manualLabel} + 1` },
|
||||
})
|
||||
);
|
||||
|
||||
if (error) {
|
||||
createLog(
|
||||
"error",
|
||||
"labeling",
|
||||
"ocp",
|
||||
"There was an error updating manual Label Ratio"
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user