Skip to content

Commit

Permalink
add log
Browse files Browse the repository at this point in the history
  • Loading branch information
overthestream committed Sep 29, 2024
1 parent d7ed516 commit 37af190
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
53 changes: 50 additions & 3 deletions src/domain/blurting/blurting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,36 @@ export class BlurtingService {
group.id,
no,
);
if (!questionToProcess || no > 9) return;
if (!questionToProcess || no > 9) {
console.log(
new Date().toString() +
'blurting question process exception no exceed:' +
no,
);
return;
}

if (questionToProcess.isUploaded) return;
if (questionToProcess.isUploaded) {
console.log(
new Date().toString() +
'already uploaded - no:' +
no +
' groupId:' +
group.id,
);
return;
}
const hour =
new Date().getHours() + 9 >= 24
? new Date().getHours() + 9 - 24
: new Date().getHours() + 9;
if (hour >= 1 && hour <= 8) {
const DNDEndsAt = new Date().setHours(23);
const delay = DNDEndsAt - new Date().getTime();

await this.rQ.add({ group, no: no, users }, { delay: delay });
console.log(new Date().toString() + 'Do not disturb me until 8am');
console.log(new Date().toString() + 'no:' + no + ' groupId:' + group.id);
return;
}
await this.insertQuestionToGroup(questionToProcess.question, group, no);
Expand All @@ -91,18 +110,39 @@ export class BlurtingService {
);
}),
);
console.log(
new Date().toString() +
'question uploaded - no:' +
no +
' groupId:' +
group.id,
);
await this.blurtingPreQuestionRepository.updateToUpload(
questionToProcess.id,
);
if (no === 9) return;
if (no === 9) {
console.log(new Date().toString() + 'blurting end - groupId:' + group.id);
return;
}

if (no % 3 === 0) {
console.log(new Date().toString() + 'part end - groupId:' + group.id);
const nextPartStartsAt = new Date(
group.createdAt.getTime() + (no / 3) * (3 * 60 * 60 * 1000),
);
const delay = new Date().getTime() - nextPartStartsAt.getTime();
await this.rQ.add({ group, no: no + 1, users }, { delay: delay });
console.log(
new Date().toString() +
'next part start at: ' +
nextPartStartsAt.toString() +
' - groupId:' +
group.id,
);
} else {
console.log(
new Date().toString() + 'question added: ' + ' - groupId:' + group.id,
);
await this.rQ.add(
{ group, no: no + 1, users },
{ delay: 60 * 60 * 1000 },
Expand Down Expand Up @@ -149,6 +189,13 @@ export class BlurtingService {
question: QUESTION3[rand],
});
}
console.log(
new Date().toString() + 'pre questions added, groupId:',
group.id,
);
console.log(new Date().toString() + QUESTION1);
console.log(new Date().toString() + QUESTION2);
console.log(new Date().toString() + QUESTION3);
}

async createGroup(users: number[]): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/validation/validation.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ValidationController {
@Get('/admob')
@ValidationDocs('admobValidation')
async admobValidation(@Req() req: Request) {

console.log('admob:' + req.url);
this.validationService.validateAdMob(req.url);
}

Expand Down

0 comments on commit 37af190

Please sign in to comment.