forked from pinks/eris
refactor: optimize jobs endpoint output
This commit is contained in:
parent
84ad11b709
commit
e270a3ab1f
|
@ -4,12 +4,29 @@ import { generationQueue } from "../app/generationQueue.ts";
|
|||
export const jobsRoute = createMethodFilter({
|
||||
GET: createEndpoint(
|
||||
{ query: null, body: null },
|
||||
async () => ({
|
||||
async () => {
|
||||
const allJobs = await generationQueue.getAllJobs();
|
||||
const filteredJobsData = allJobs.map((job) => ({
|
||||
id: job.id,
|
||||
place: job.place,
|
||||
state: {
|
||||
from: {
|
||||
language_code: job.state.from.language_code,
|
||||
first_name: job.state.from.first_name,
|
||||
last_name: job.state.from.last_name,
|
||||
username: job.state.from.username,
|
||||
},
|
||||
progress: job.state.progress,
|
||||
workerInstanceKey: job.state.workerInstanceKey,
|
||||
},
|
||||
}));
|
||||
return {
|
||||
status: 200,
|
||||
body: {
|
||||
type: "application/json",
|
||||
data: await generationQueue.getAllJobs(),
|
||||
data: filteredJobsData,
|
||||
},
|
||||
};
|
||||
},
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue