Update logging

This commit is contained in:
Darren Clarke 2025-01-22 17:50:38 +01:00
parent def602c05e
commit 810a333429
39 changed files with 85 additions and 139 deletions

View file

@ -43,14 +43,11 @@ const getLabelStudioTickets = async (
page_size: "50",
page: `${page}`,
});
console.log({ url: `${labelStudioApiUrl}/projects/1/tasks?${ticketsQuery}` });
const res = await fetch(
`${labelStudioApiUrl}/projects/1/tasks?${ticketsQuery}`,
{ headers },
);
console.log({ res });
const tasksResult: any = await res.json();
console.log({ tasksResult });
return tasksResult;
};
@ -63,14 +60,11 @@ const fetchFromLabelStudio = async (
for await (const page of pages) {
const docs = await getLabelStudioTickets(page + 1);
console.log({ page, docs });
if (docs && docs.length > 0) {
for (const doc of docs) {
const updatedAt = new Date(doc.updated_at);
console.log({ updatedAt, minUpdatedTimestamp });
if (updatedAt > minUpdatedTimestamp) {
console.log(`Adding doc`, { doc });
allDocs.push(doc);
}
}
@ -79,7 +73,6 @@ const fetchFromLabelStudio = async (
}
}
console.log({ allDocs });
return allDocs;
};
@ -93,9 +86,7 @@ const sendToLeafcutter = async (tickets: LabelStudioTicket[]) => {
},
} = config;
console.log({ tickets });
const filteredTickets = tickets.filter((ticket) => ticket.is_labeled);
console.log({ filteredTickets });
const finalTickets: LeafcutterTicket[] = filteredTickets.map((ticket) => {
const {
id,
@ -131,8 +122,7 @@ const sendToLeafcutter = async (tickets: LabelStudioTicket[]) => {
};
});
console.log("Sending to Leafcutter");
console.log({ finalTickets });
console.info("Sending to Leafcutter");
const result = await fetch(opensearchApiUrl, {
method: "POST",
@ -157,15 +147,7 @@ const importLeafcutterTask = async (): Promise<void> => {
? new Date(res.value.minUpdatedTimestamp as string)
: new Date("2023-03-01");
const newLastTimestamp = new Date();
console.log({
contributorName,
settingName,
res,
startTimestamp,
newLastTimestamp,
});
const tickets = await fetchFromLabelStudio(startTimestamp);
console.log({ tickets });
await sendToLeafcutter(tickets);
await db.settings.upsert(settingName, {
minUpdatedTimestamp: newLastTimestamp,