Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #279 from SE-TINF22B2/backend/fixed-disable-ai
Browse files Browse the repository at this point in the history
BE: fixed disable ai in getAnswers
  • Loading branch information
Jozys authored Jun 19, 2024
2 parents 03e790d + 5f74a6a commit 264ae8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 2 additions & 5 deletions backend/src/database/user-content/user-content.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,13 @@ export class UserContentService {
sortOptions: SortOptions,
enableAI: boolean,
): Promise<UserContentWithRating[] | null> {
const ai = enableAI ? {} : { typeOfAI: TypeOfAI.None, };
const answers: UserContent[] | null =
await this.prisma.userContent.findMany({
where: {
groupID: groupID,
type: UserContentType.Answer,
answer: enableAI
? {}
: {
typeOfAI: TypeOfAI.None,
},
answer: ai,
},
});
if (null === answers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ export class UserContentRequestService {
if (null === question || null === question.userContent)
throw new NotFoundException('No question found with this id.');

// @ts-ignore // sometimes a boolean is not a boolean
const enableAI = sortCriteria.enableAI == 'true';

// fetch answers
const rawAnswers = await this.userContentService.getAnswersOfGroupID(
question.userContent.groupID,
Expand All @@ -233,7 +236,7 @@ export class UserContentRequestService {
sortCriteria.offset,
sortCriteria.limit,
),
sortCriteria.enableAI,
enableAI,
);
if (rawAnswers == null) {
throw new InternalServerErrorException(
Expand Down

0 comments on commit 264ae8c

Please sign in to comment.