Skip to content

Commit

Permalink
Merge pull request #6 from Wanted-Free-Pre-Onboarding-Course-10/feature/
Browse files Browse the repository at this point in the history
#3

Refactoring : 리스트 API 수정
  • Loading branch information
YeomJaeSeon authored Nov 16, 2021
2 parents 734587e + d21ce98 commit 17c75dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/pr.yml

This file was deleted.

5 changes: 3 additions & 2 deletions src/subject/subject.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';

@Entity()
Expand All @@ -13,8 +14,8 @@ export class Subject {
@CreateDateColumn({ name: 'created_at', nullable: false })
createdAt: Date;

@Column({ name: 'last_modified', nullable: true })
last_modified: Date;
@UpdateDateColumn({ name: 'update_at', nullable: true })
updateAt: Date;

@Column({ name: 'name', nullable: false })
name: string;
Expand Down
4 changes: 3 additions & 1 deletion src/subject/subject.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ export class SubjectService {
async getPostListByUpdate(pageInfo: GetListDto) {
const nowDate = new Date();
const dayOfMonth = nowDate.getDate();

nowDate.setDate(dayOfMonth - 7);
const subjectList = await this.subjectRepository
.createQueryBuilder('subject')
.where(`subject.last_modified > ${moment(nowDate).format('YYYY-MM-DD')}`)
.where('subject.createdAt != subject.updateAt')
.andWhere(`subject.updateAt > ${moment(nowDate).format('YYYY-MM-DD')}`)
.orderBy('subject.id', 'DESC')
.limit(pageInfo.limit)
.offset(pageInfo.offset)
Expand Down

0 comments on commit 17c75dd

Please sign in to comment.