Skip to content

Commit

Permalink
feat: add notice with treating createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
2paperstar committed Nov 23, 2023
1 parent 1fe8ff6 commit deecf27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/notice/notice.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export class NoticeRepository {
async createNotice(
{ title, body, deadline, tags, images }: CreateNoticeDto,
userUuid: string,
createdAt?: Date,
) {
const findedTags = await this.prismaService.tag.findMany({
where: {
Expand Down Expand Up @@ -240,6 +241,7 @@ export class NoticeRepository {
url: image,
})),
},
createdAt,
},
})
.catch((err) => {
Expand Down
4 changes: 2 additions & 2 deletions src/notice/notice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class NoticeService {
return { files, content };
}

@Cron('30 * * * * *')
@Cron('0 */30 * * *')
async crawlAcademicNotice() {
const notices = await this.getAcademicNoticeList();
const recentNotice = await this.noticeRepository.getNoticeList({
Expand All @@ -278,7 +278,6 @@ export class NoticeService {
);
const noticesToCreate = await firstValueFrom(noticesToCreate$);
for (const noticeMetadata of noticesToCreate) {
console.log(noticeMetadata.title);
const notice = await this.getAcademicNotice(noticeMetadata.link);
const filesList = notice.files
.map((file) => `<li><a href="${file.href}">${file.name}</a></li>`)
Expand All @@ -300,6 +299,7 @@ export class NoticeService {
tags: tags.map(({ id }) => id),
},
user.uuid,
dayjs(noticeMetadata.createdAt).tz('Asia/Seoul').toDate(),
);
}
}
Expand Down

0 comments on commit deecf27

Please sign in to comment.