feat: pending tickets remote at the top of the ticket list
parent
3574b2d8af
commit
0866cbce79
|
@ -1,4 +1,9 @@
|
||||||
|
import { values } from "sequelize/types/lib/operators";
|
||||||
|
import Ticket from "../models/Ticket";
|
||||||
import { get, set } from "./RedisClient";
|
import { get, set } from "./RedisClient";
|
||||||
|
import { getIO } from "../libs/socket";
|
||||||
|
import UpdateTicketService from "../services/TicketServices/UpdateTicketService";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
|
||||||
async function controllByNumber() {
|
async function controllByNumber() {
|
||||||
let tickets = await get({ key: "remote:ticketId*", parse: false });
|
let tickets = await get({ key: "remote:ticketId*", parse: false });
|
||||||
|
@ -33,6 +38,21 @@ async function controllByNumber() {
|
||||||
|
|
||||||
const ticketIds = controll.map((c: any) => c.ticketId);
|
const ticketIds = controll.map((c: any) => c.ticketId);
|
||||||
|
|
||||||
|
console.log("=======> ticketIds: ", ticketIds);
|
||||||
|
|
||||||
|
for (const ticketId of ticketIds) {
|
||||||
|
const ticket: any = await Ticket.findByPk(ticketId);
|
||||||
|
|
||||||
|
const { status } = ticket;
|
||||||
|
|
||||||
|
if (status == "pending") {
|
||||||
|
await UpdateTicketService({
|
||||||
|
ticketData: { statusChatEnd: uuidv4() },
|
||||||
|
ticketId: ticket.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set(`remote:controll`, JSON.stringify(ticketIds));
|
set(`remote:controll`, JSON.stringify(ticketIds));
|
||||||
|
|
||||||
return { ticketIds, tickets };
|
return { ticketIds, tickets };
|
||||||
|
|
Loading…
Reference in New Issue