Skip to content

Commit

Permalink
fix: get only having deadline notices when query with deadline order
Browse files Browse the repository at this point in the history
  • Loading branch information
2paperstar committed Nov 15, 2023
1 parent 87f73d7 commit 75482c8
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions src/notice/notice.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
NotFoundException,
} from '@nestjs/common';
import { FcmToken, FileType } from '@prisma/client';
import { PrismaService } from 'src/prisma/prisma.service';
import { GetAllNoticeQueryDto } from './dto/getAllNotice.dto';
import { NoticeFullcontent } from './types/noticeFullcontent';
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library';
import { CreateNoticeDto } from './dto/createNotice.dto';
import dayjs from 'dayjs';
import { PrismaService } from 'src/prisma/prisma.service';
import { AdditionalNoticeDto } from './dto/additionalNotice.dto';
import { CreateNoticeDto } from './dto/createNotice.dto';
import { ForeignContentDto } from './dto/foreignContent.dto';
import dayjs from 'dayjs';
import { GetAllNoticeQueryDto } from './dto/getAllNotice.dto';
import { NoticeFullcontent } from './types/noticeFullcontent';
import { NoticeReminder } from './types/noticeReminer';

@Injectable()
Expand Down Expand Up @@ -88,19 +88,14 @@ export class NoticeRepository {
createdAt: orderBy === 'recent' ? 'desc' : undefined,
},
where: {
...(orderBy === 'deadline'
? { currentDeadline: { gte: dayjs().startOf('d').toDate() } }
: {}),
deletedAt: null,
authorId: my === 'own' ? userUuid : undefined,
reminders:
my === 'reminders'
? {
some: {
uuid: userUuid,
},
}
: undefined,
tags: tags && {
some: { name: { in: tags } },
},
my === 'reminders' ? { some: { uuid: userUuid } } : undefined,
tags: tags && { some: { name: { in: tags } } },
OR: [
{
contents: {
Expand All @@ -115,33 +110,14 @@ export class NoticeRepository {
},
},
},
{
tags: {
some: {
name: { contains: search },
},
},
},
{ tags: { some: { name: { contains: search } } } },
],
},
include: {
tags: true,
contents: {
orderBy: {
id: 'asc',
},
take: 1,
},
author: {
select: {
name: true,
},
},
files: {
where: {
type: FileType.IMAGE,
},
},
contents: { orderBy: { id: 'asc' }, take: 1 },
author: { select: { name: true } },
files: { where: { type: FileType.IMAGE } },
},
})
.catch((err) => {
Expand Down

0 comments on commit 75482c8

Please sign in to comment.