Skip to content

Commit

Permalink
blurting4
Browse files Browse the repository at this point in the history
  • Loading branch information
overthestream committed Sep 18, 2024
1 parent 92d7daf commit 5e9cd18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/domain/blurting/blurting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ export class BlurtingService {
if (groupQueue.includes(user.id)) {
return State.Matching;
}
if (user.group && (await this.checkPartOver(user.group.id))) {
return State.Arrowing;
}
if (user.group && this.checkGroupOver(user.group.id)) {
if (await this.checkPartOver(user.group.id)) {
return State.Arrowing;
}
return State.Blurting;
}
if (user.group) {
Expand Down Expand Up @@ -349,10 +349,17 @@ export class BlurtingService {

async checkPartOver(groupId: number): Promise<boolean> {
const question = await this.questionRepository.findLatestByGroup(groupId);

if (question.no % 3 === 0) {
return await this.checkAllAnswered(question.id);
return (
(await this.checkAllAnswered(question.id)) ||
question.createdAt.getTime() - new Date().getTime() > 60 * 60 * 1000
);
}
return false;
return (
false ||
question.createdAt.getTime() - new Date().getTime() > 60 * 60 * 1000
);
}

async checkGroupOver(groupId: number): Promise<boolean> {
Expand Down
4 changes: 4 additions & 0 deletions src/domain/entities/blurtingQuestion.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Column,
CreateDateColumn,
Entity,
ManyToOne,
OneToMany,
Expand All @@ -18,6 +19,9 @@ export class BlurtingQuestionEntity {
@Column()
no: number;

@CreateDateColumn()
createdAt: Date;

@Column()
question: string;

Expand Down

0 comments on commit 5e9cd18

Please sign in to comment.