MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / serializeTask

Function serializeTask

js/botasaurus-server-js/src/models.ts:218–246  ·  view source on GitHub ↗
(obj: Task, withResult: boolean)

Source from the content-addressed store, hash-verified

216}
217
218async function serializeTask(obj: Task, withResult: boolean): Promise<any> {
219 const taskId = obj.id;
220 const status = obj.status;
221 let result = {};
222
223 if (withResult) {
224 result = await fetchTaskResult(status, result, obj, taskId)
225 }
226 return {
227 id: taskId,
228 status: status,
229 task_name: createTaskName(obj.task_name, taskId),
230 scraper_name: obj.scraper_name,
231 scraper_type: obj.scraper_type,
232 is_all_task: obj.is_all_task,
233 priority: obj.priority,
234 is_large: obj.is_large,
235 parent_task_id: obj.parent_task_id,
236 duration: calculateDuration(obj),
237 started_at: isoformat(obj.started_at),
238 finished_at: isoformat(obj.finished_at),
239 data: obj.data,
240 metadata: obj.meta_data,
241 ...result,
242 result_count: obj.result_count,
243 created_at: isoformat(obj.created_at),
244 updated_at: isoformat(obj.updated_at),
245 };
246}
247export type StatusKind = typeof TaskStatus[keyof typeof TaskStatus]
248
249// Task model

Callers 2

serializeTaskForDownloadFunction · 0.90
toJsonMethod · 0.85

Calls 4

fetchTaskResultFunction · 0.85
createTaskNameFunction · 0.85
calculateDurationFunction · 0.85
isoformatFunction · 0.70

Tested by

no test coverage detected