Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpacaFur committed Apr 15, 2024
1 parent 587c239 commit 485377a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
File renamed without changes.
35 changes: 16 additions & 19 deletions packages/api/src/major/major.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,35 @@ import {
} from "@graduate/common";
import { Injectable, Logger } from "@nestjs/common";
import { formatServiceCtx } from "../utils";
// import { SUPPORTED_MAJOR_YEARS, SUPPORTED_MAJORS } from "./majors";
import { MAJOR_YEARS, MAJORS } from "./majorCollator";
import { MAJOR_YEARS, MAJORS } from "./major-collator";

@Injectable()
export class MajorService {
private readonly logger: Logger = new Logger();

findByMajorAndYear(majorName: string, catalogYear: number): Major2 | null {
// if (!SUPPORTED_MAJOR_YEARS.includes(catalogYear.toString())) {
// this.logger.debug(
// { mesage: "Major year not found", catalogYear },
// MajorService.formatMajorServiceCtx("findByMajorAndYear")
// );
// return null;
// }

// const { majors, supportedMajorNames } = SUPPORTED_MAJORS[catalogYear];
// if (!supportedMajorNames.includes(majorName)) {
// this.logger.debug(
// { mesage: "Major within year not found", majorName, catalogYear },
// MajorService.formatMajorServiceCtx("findByMajorAndYear")
// );
// return null;
// }
if (!MAJOR_YEARS.has(String(catalogYear))) {
this.logger.debug(
{ mesage: "Major year not found", catalogYear },
MajorService.formatMajorServiceCtx("findByMajorAndYear")
);
return null;
}

if (!MAJORS[catalogYear][majorName]) {
this.logger.debug(
{ mesage: "Major within year not found", majorName, catalogYear },
MajorService.formatMajorServiceCtx("findByMajorAndYear")
);
return null;
}

return MAJORS[catalogYear][majorName];
}

getSupportedMajors(): SupportedMajors {
const supportedMajors: SupportedMajors = {};
MAJOR_YEARS.forEach((year) => {
console.log(MAJOR_YEARS, MAJORS);
const supportedMajorNames = Object.keys(MAJORS[year]);

const supportedMajorForYear: SupportedMajorsForYear = {};
Expand Down

0 comments on commit 485377a

Please sign in to comment.