Skip to content

Commit

Permalink
fix: Sync related bug (#147)
Browse files Browse the repository at this point in the history
* fix: Do not touch auto generated fields

* fix: Add missing /api segment in route

* fix: Call trim for all cases for safekeeping
  • Loading branch information
doxylee authored Dec 10, 2024
1 parent 9f9119c commit 7d27346
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/modules/sync/sync.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { toJsonSemester } from 'src/common/interfaces/serializer/semester.serial
import { SyncScholarDBService } from './syncScholarDB.service';
import { SyncTakenLectureService } from './syncTakenLecture.service';

@Controller('sync')
@Controller('api/sync')
export class SyncController {
constructor(
private readonly syncScholarDBService: SyncScholarDBService,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/sync/syncScholarDB.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class SyncScholarDBService {
const foundLecture = existingLectures.find(
(l) =>
l.code === lecture.subject_no &&
l.class_no === lecture.lecture_class.trim(),
l.class_no.trim() === lecture.lecture_class.trim(),
);
const course_id = courseMap.get(lecture.old_no)?.id;
if (!course_id)
Expand Down Expand Up @@ -529,7 +529,7 @@ export class SyncScholarDBService {
const lecture = existingLectures.find(
(l) =>
l.code === time.subject_no &&
l.class_no === time.lecture_class.trim(),
l.class_no.trim() === time.lecture_class.trim(),
);
if (!lecture) {
result.skipped.push({
Expand Down
6 changes: 0 additions & 6 deletions src/prisma/repositories/sync.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ export class SyncRepository {
type_en: data.type_en,
title: data.title,
title_en: data.title_en,
title_en_no_space: data.title_en.replace(/\s/g, ''),
title_no_space: data.title.replace(/\s/g, ''),
summury: '',
grade_sum: 0,
load_sum: 0,
Expand All @@ -120,8 +118,6 @@ export class SyncRepository {
where: { id },
data: {
...data,
title_no_space: data.title && data.title.replace(/\s/g, ''),
title_en_no_space: data.title_en && data.title_en.replace(/\s/g, ''),
},
});
}
Expand Down Expand Up @@ -159,8 +155,6 @@ export class SyncRepository {
data: {
...data,
deleted: false,
title_no_space: data.title.replace(/\s/g, ''),
title_en_no_space: data.title_en.replace(/\s/g, ''),
grade_sum: 0,
load_sum: 0,
speech_sum: 0,
Expand Down
8 changes: 4 additions & 4 deletions src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ model subject_course {
load Float
speech Float
latest_written_datetime DateTime? @db.DateTime(0)
title_no_space String @db.VarChar(100)
title_en_no_space String @db.VarChar(200)
title_no_space String @default(dbgenerated()) @db.VarChar(100)
title_en_no_space String @default(dbgenerated()) @db.VarChar(200)
main_relatedcoursedailyuserfeed main_relatedcoursedailyuserfeed[]
planner_futureplanneritem planner_futureplanneritem[]
review review_review[]
Expand Down Expand Up @@ -513,8 +513,8 @@ model subject_lecture {
class_title_en String? @db.VarChar(100)
common_title String? @db.VarChar(100)
common_title_en String? @db.VarChar(100)
title_no_space String @db.VarChar(100)
title_en_no_space String @db.VarChar(200)
title_no_space String @default(dbgenerated()) @db.VarChar(100)
title_en_no_space String @default(dbgenerated()) @db.VarChar(200)
main_reviewwritedailyuserfeed main_reviewwritedailyuserfeed[]
planner_takenplanneritem planner_takenplanneritem[]
review review_review[]
Expand Down

0 comments on commit 7d27346

Please sign in to comment.