Skip to content

Commit

Permalink
mass confirm fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Jul 22, 2024
1 parent c4bdc59 commit 225c23a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
30 changes: 20 additions & 10 deletions src/features/need/need.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,16 @@ export class NeedController {

const validatedNeed = await validateNeed(fetchedNeed, superAdmin);
let ticket: TicketEntity;

let needTickets = await this.ticketService.getTicketsByNeed(
validatedNeed.needId,
);
const ticketError = needTickets.find(
(t) =>
t.lastAnnouncement === AnnouncementEnum.ERROR ||
t.color === Colors.RED,
);
// 0- ticket if not a valid need and not ticketed yet
if (!validatedNeed.isValidNeed) {
let needTickets = await this.ticketService.getTicketsByNeed(
validatedNeed.needId,
);
const ticketError = needTickets.find(
(t) =>
t.lastAnnouncement === AnnouncementEnum.ERROR ||
t.color === Colors.RED,
);

// create ticket if already has not
if (!ticketError) {
console.log('\x1b[36m%s\x1b[0m', 'Creating Ticket Content ...\n');
Expand Down Expand Up @@ -422,6 +420,18 @@ export class NeedController {
continue;
}
/// -------------------------------- If Valid Need --------------------------------------------///
if (ticketError) {
// since it is a valid need with an old ticket, we need to update the ticket
await this.ticketService.updateTicketAnnouncement(
ticketError.id,
AnnouncementEnum.NONE,
);

await this.ticketService.updateTicketColor(
ticketError.id,
Colors.BLUE,
);
}
// 1- get duplicates for the child / same name-translations.en
const duplicates = await this.needService.getDuplicateNeeds(
need.child_id,
Expand Down
4 changes: 2 additions & 2 deletions src/features/schedule/schedule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export class ScheduleService {
}
}

@Cron('50 12 * * Sat', {
name: 'Reminders to announce arrivals At 12:50 on Sat.',
@Cron('50 9 * * Wed', {
name: 'Reminders to announce arrivals At 9:50 on Wednesday.',
timeZone: 'Asia/Tehran',
})
async handleAnnounceArrivalCron() {
Expand Down
2 changes: 1 addition & 1 deletion src/features/ticket/ticket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class TicketService {
}
}

createTicketContent(
async createTicketContent(
contentDetails: CreateTicketContentParams,
ticket: TicketEntity,
): Promise<TicketContentEntity> {
Expand Down

0 comments on commit 225c23a

Please sign in to comment.