Cron completo y mejora de logs
This commit is contained in:
@@ -2,6 +2,7 @@ import { Result } from "sim-shared/domain/Result.js";
|
||||
import { QueryResult } from "pg";
|
||||
import { PgClient } from "sim-shared/infrastructure/PgClient.js";
|
||||
import { AxiosError } from "axios";
|
||||
import { ActionData } from "#domain/DTOs/objeniousapi.js";
|
||||
|
||||
export type PauseCancelTask = {
|
||||
id: number;
|
||||
@@ -12,9 +13,10 @@ export type PauseCancelTask = {
|
||||
next_check?: Date | null;
|
||||
completed_date?: Date | null;
|
||||
error?: string | null;
|
||||
actionData: ActionData
|
||||
}
|
||||
|
||||
export type CreatePauseCancelTaskDTO = Pick<PauseCancelTask, "iccid" | "activation_date" | "next_check" | "operation_type">
|
||||
export type CreatePauseCancelTaskDTO = Pick<PauseCancelTask, "iccid" | "activation_date" | "next_check" | "operation_type" | "actionData">
|
||||
export type UpdatePauseCancelTaskDTO = Pick<PauseCancelTask, "id" | "next_check">
|
||||
export type FinishPauseCancelTaskDTO = Pick<PauseCancelTask, "id" | "error">
|
||||
|
||||
@@ -55,12 +57,12 @@ export class PauseCancelTaskRepository {
|
||||
public async addTask(task: CreatePauseCancelTaskDTO): Promise<Result<string, PauseCancelTask>> {
|
||||
|
||||
const sql = `
|
||||
INSERT INTO pause_cancel_tasks (iccid, activation_date, next_check, last_checked, operation_type)
|
||||
VALUES ($1, $2, $3, now(), $4)
|
||||
INSERT INTO pause_cancel_tasks (iccid, activation_date, next_check, last_checked, operation_type, actionData)
|
||||
VALUES ($1, $2, $3, now(), $4, $5)
|
||||
RETURNING *;
|
||||
`;
|
||||
try {
|
||||
const values = [task.iccid, task.activation_date, task.next_check, task.operation_type];
|
||||
const values = [task.iccid, task.activation_date, task.next_check, task.operation_type, JSON.stringify(task.actionData)];
|
||||
const res: QueryResult<PauseCancelTask> = await this.pgClient.query(sql, values);
|
||||
return {
|
||||
data: res.rows[0]
|
||||
|
||||
Reference in New Issue
Block a user