Skip to content

Commit

Permalink
Merge pull request #103 from Boost-Coder/feature/roundScore-#102
Browse files Browse the repository at this point in the history
[#102] 모든 점수들을 소수점 2째자리에서 반올림 하도록 수정
  • Loading branch information
namewhat99 authored Jun 5, 2024
2 parents bc52907 + 5f8469b commit 052b81b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/Entity/algorithm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
BeforeInsert,
BeforeUpdate,
Column,
CreateDateColumn,
Entity,
Expand Down Expand Up @@ -35,7 +37,7 @@ export class Algorithm {
@Column()
solvedCount: number;

@Column('double')
@Column('decimal', { precision: 10, scale: 2 })
score: number;

@CreateDateColumn({
Expand All @@ -53,4 +55,10 @@ export class Algorithm {
@OneToOne(() => User, (user) => user.userId, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'user_id', referencedColumnName: 'userId' })
user: User;

@BeforeInsert()
@BeforeUpdate()
roundAmount() {
this.score = Math.round(this.score * 100) / 100;
}
}
10 changes: 9 additions & 1 deletion src/Entity/github.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
BeforeInsert,
BeforeUpdate,
Column,
CreateDateColumn,
Entity,
Expand All @@ -23,7 +25,7 @@ export class Github {
@Column()
githubId: number;

@Column('double')
@Column('decimal', { precision: 10, scale: 2 })
score: number;

@Column()
Expand All @@ -44,4 +46,10 @@ export class Github {
@OneToOne(() => User, (user) => user.userId, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'user_id', referencedColumnName: 'userId' })
user: User;

@BeforeInsert()
@BeforeUpdate()
roundAmount() {
this.score = Math.round(this.score * 100) / 100;
}
}
10 changes: 9 additions & 1 deletion src/Entity/grade.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
BeforeInsert,
BeforeUpdate,
Column,
CreateDateColumn,
Entity,
Expand All @@ -23,7 +25,7 @@ export class Grade {
@Column('double')
grade: number;

@Column('double')
@Column('decimal', { precision: 10, scale: 2 })
score: number;

@CreateDateColumn({
Expand All @@ -41,4 +43,10 @@ export class Grade {
@OneToOne(() => User, (user) => user.userId, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'user_id', referencedColumnName: 'userId' })
user: User;

@BeforeInsert()
@BeforeUpdate()
roundAmount() {
this.score = Math.round(this.score * 100) / 100;
}
}
10 changes: 9 additions & 1 deletion src/Entity/totalPoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
BeforeInsert,
BeforeUpdate,
Column,
CreateDateColumn,
Entity,
Expand All @@ -20,7 +22,7 @@ export class TotalPoint {
})
userId: string;

@Column('double')
@Column('decimal', { precision: 10, scale: 2 })
score: number;

@CreateDateColumn({
Expand All @@ -35,6 +37,12 @@ export class TotalPoint {
})
updateDate: Date;

@BeforeInsert()
@BeforeUpdate()
roundAmount() {
this.score = Math.round(this.score * 100) / 100;
}

@OneToOne(() => User, (user) => user.userId, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'user_id', referencedColumnName: 'userId' })
user: User;
Expand Down

0 comments on commit 052b81b

Please sign in to comment.