Skip to content

Commit

Permalink
N21-2095 clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrikallab committed Jul 23, 2024
1 parent 43b6a25 commit af1cd19
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions apps/server/src/modules/group/uc/class-group.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ export class ClassGroupUc {

switch (schoolYearQueryType) {
case SchoolYearQueryType.CURRENT_YEAR:
return schoolYear.startDate === currentYear.getProps().startDate;
return schoolYear.startDate === currentYear.startDate;
case SchoolYearQueryType.NEXT_YEAR:
return schoolYear.startDate > currentYear.getProps().startDate;
return schoolYear.startDate > currentYear.startDate;
case SchoolYearQueryType.PREVIOUS_YEARS:
return schoolYear.startDate < currentYear.getProps().startDate;
return schoolYear.startDate < currentYear.startDate;
default:
throw new UnknownQueryTypeLoggableException(schoolYearQueryType);
}
Expand Down
6 changes: 5 additions & 1 deletion apps/server/src/modules/school/domain/do/school-year.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object';

export class SchoolYear extends DomainObject<SchoolYearProps> {}
export class SchoolYear extends DomainObject<SchoolYearProps> {
get startDate() {
return this.props.startDate;
}
}

export interface SchoolYearProps extends AuthorizableObject {
name: string;
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/modules/school/domain/do/school.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ interface SchoolInfo {
}

export class School extends DomainObject<SchoolProps> {
get currentYear() {
return this.props.currentYear;
}

get systems(): EntityId[] {
return this.props.systemIds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class SchoolService {

public async getCurrentYear(schoolId: EntityId) {
const school = await this.getSchoolById(schoolId);
return school.getProps().currentYear;
return school.currentYear;
}

public async doesSchoolExist(schoolId: EntityId): Promise<boolean> {
Expand Down

0 comments on commit af1cd19

Please sign in to comment.