Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(rewrite) remove old models and rename new models #796

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apps/backend/src/modules/catalog/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import Fuse from "fuse.js";
import { GraphQLResolveInfo } from "graphql";

import {
ClassModel,
CourseModel,
GradeDistributionModel,
IClassItem,
ICourseItem,
IGradeDistributionItem,
ISectionItem,
NewClassModel,
NewCourseModel,
NewSectionModel,
NewTermModel,
SectionModel,
TermModel,
} from "@repo/common";

import { getFields } from "../../utils/graphql";
Expand Down Expand Up @@ -363,7 +363,7 @@ export const getCatalog = async (
info: GraphQLResolveInfo,
query?: string | null
) => {
const term = await NewTermModel.findOne({
const term = await TermModel.findOne({
name: `${year} ${semester}`,
})
.select({ _id: 1 })
Expand All @@ -384,7 +384,7 @@ export const getCatalog = async (
*/

// Fetch available classes for the term
const classes = await NewClassModel.find({
const classes = await ClassModel.find({
year,
semester,
anyPrintInScheduleOfClasses: true,
Expand All @@ -394,13 +394,13 @@ export const getCatalog = async (
const courseIds = classes.map((_class) => _class.courseId);

// Fetch available courses for the term
const courses = await NewCourseModel.find({
const courses = await CourseModel.find({
courseId: { $in: courseIds },
printInCatalog: true,
}).lean();

// Fetch available sections for the term
const sections = await NewSectionModel.find({
const sections = await SectionModel.find({
year,
semester,
courseId: { $in: courseIds },
Expand Down
14 changes: 8 additions & 6 deletions apps/backend/src/modules/class/controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
ClassModel,
IClassItem,
ISectionItem,
NewClassModel,
NewSectionModel,
SectionModel,
} from "@repo/common";

import { formatClass, formatSection } from "./formatter";
Expand All @@ -15,7 +15,7 @@ export const getClass = async (
courseNumber: string,
number: string
) => {
const _class = await NewClassModel.findOne({
const _class = await ClassModel.findOne({
year,
semester,
sessionId: sessionId ? sessionId : "1",
Expand All @@ -24,6 +24,8 @@ export const getClass = async (
number,
}).lean();

console.log(await ClassModel.countDocuments({}));

if (!_class) return null;

return formatClass(_class as IClassItem);
Expand All @@ -37,7 +39,7 @@ export const getSecondarySections = async (
courseNumber: string,
number: string
) => {
const sections = await NewSectionModel.find({
const sections = await SectionModel.find({
year,
semester,
sessionId: sessionId ? sessionId : "1",
Expand All @@ -57,7 +59,7 @@ export const getPrimarySection = async (
courseNumber: string,
number: string
) => {
const section = await NewSectionModel.findOne({
const section = await SectionModel.findOne({
year,
semester,
sessionId: sessionId ? sessionId : "1",
Expand All @@ -80,7 +82,7 @@ export const getSection = async (
courseNumber: string,
number: string
) => {
const section = await NewSectionModel.findOne({
const section = await SectionModel.findOne({
year,
semester,
sessionId: sessionId ? sessionId : "1",
Expand Down
16 changes: 5 additions & 11 deletions apps/backend/src/modules/course/controller.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import {
CourseModel,
IClassItem,
ICourseItem,
NewClassModel,
NewCourseModel,
} from "@repo/common";
import { ClassModel, CourseModel, IClassItem, ICourseItem } from "@repo/common";

import { formatClass } from "../class/formatter";
import { IntermediateCourse, formatCourse } from "./formatter";
import { CourseModule } from "./generated-types/module-types";

export const getCourse = async (subject: string, number: string) => {
const course = await NewCourseModel.findOne({ subject, number })
const course = await CourseModel.findOne({ subject, number })
.sort({ fromDate: -1 })
.lean();

Expand All @@ -21,7 +15,7 @@ export const getCourse = async (subject: string, number: string) => {
};

export const getClassesByCourse = async (courseId: string) => {
const classes = await NewClassModel.find({
const classes = await ClassModel.find({
courseId,
}).lean();

Expand All @@ -43,7 +37,7 @@ export const getAssociatedCoursesBySubjectNumber = async (
};
});

const associatedCourses = await NewCourseModel.find({
const associatedCourses = await CourseModel.find({
$or: queries,
})
.sort({ fromDate: -1 })
Expand All @@ -65,7 +59,7 @@ export const getAssociatedCoursesBySubjectNumber = async (
};

export const getAssociatedCoursesById = async (courseIds: string[]) => {
const associatedCourses = await NewCourseModel.find({
const associatedCourses = await CourseModel.find({
courseId: { $in: courseIds },
})
.sort({ fromDate: -1 })
Expand Down
8 changes: 4 additions & 4 deletions apps/backend/src/modules/grade-distribution/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
GradeDistributionModel,
IGradeDistributionItem,
NewSectionModel,
SectionModel,
} from "@repo/common";

enum Letter {
Expand Down Expand Up @@ -191,7 +191,7 @@ export const getGradeDistributionByClass = async (
courseNumber: string,
sectionNumber: string
) => {
const section = await NewSectionModel.findOne({
const section = await SectionModel.findOne({
year,
semester,
sessionId: sessionId ? sessionId : "1",
Expand Down Expand Up @@ -254,7 +254,7 @@ export const getGradeDistributionByInstructor = async (
familyName: string,
givenName: string
) => {
const sections = await NewSectionModel.find({
const sections = await SectionModel.find({
subject,
courseNumber,
"meetings.instructors.familyName": familyName,
Expand Down Expand Up @@ -291,7 +291,7 @@ export const getGradeDistributionByInstructorAndSemester = async (
familyName: string,
givenName: string
) => {
const sections = await NewSectionModel.find({
const sections = await SectionModel.find({
year,
semester,
sessionId: sessionId ? sessionId : "1",
Expand Down
12 changes: 6 additions & 6 deletions apps/backend/src/modules/schedule/controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
ClassModel,
IClassItem,
NewClassModel,
NewSectionModel,
NewTermModel,
ScheduleModel,
SectionModel,
TermModel,
} from "@repo/common";

import {
Expand Down Expand Up @@ -55,7 +55,7 @@ export const createSchedule = async (
) => {
if (!context.user._id) throw new Error("Unauthorized");

const term = await NewTermModel.findOne({
const term = await TermModel.findOne({
name: `${input.year} ${input.semester}`,
})
.select({ _id: 1 })
Expand Down Expand Up @@ -114,7 +114,7 @@ export const getClasses = async (
const classes = [];

for (const selectedClass of selectedClasses) {
const _class = await NewClassModel.findOne({
const _class = await ClassModel.findOne({
year,
semester,
sessionId: sessionId ? sessionId : "1",
Expand All @@ -125,7 +125,7 @@ export const getClasses = async (

if (!_class) continue;

const sections = await NewSectionModel.find({
const sections = await SectionModel.find({
termId: _class.termId,
sessionId: _class.sessionId,
sectionId: { $in: selectedClass.sectionIds },
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/modules/term/controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NewTermModel } from "@repo/common";
import { TermModel } from "@repo/common";

import { formatTerm } from "./formatter";

Expand All @@ -20,7 +20,7 @@ const fields = {
};

export const getTerms = async () => {
const terms = await NewTermModel.find({}).select(fields).lean();
const terms = await TermModel.find({}).select(fields).lean();

return terms.map(formatTerm);
};
Expand All @@ -30,7 +30,7 @@ export const getTerm = async (
semester: string,
academicCareerCode: string = "UGRD"
) => {
const term = await NewTermModel.findOne({
const term = await TermModel.findOne({
name: `${year} ${semester}`,
academicCareerCode,
})
Expand Down
8 changes: 4 additions & 4 deletions apps/backend/src/modules/user/controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
ClassModel,
CourseModel,
IClassItem,
ICourseItem,
NewClassModel,
NewCourseModel,
UserModel,
} from "@repo/common";

Expand Down Expand Up @@ -42,7 +42,7 @@ export const getBookmarkedCourses = async (
const courses = [];

for (const bookmarkedCourse of bookmarkedCourses) {
const course = await NewCourseModel.findOne({
const course = await CourseModel.findOne({
subject: bookmarkedCourse.subject,
number: bookmarkedCourse.number,
})
Expand All @@ -63,7 +63,7 @@ export const getBookmarkedClasses = async (
const classes = [];

for (const bookmarkedClass of bookmarkedClasses) {
const _class = await NewClassModel.findOne({
const _class = await ClassModel.findOne({
year: bookmarkedClass.year,
semester: bookmarkedClass.semester,
sessionId: bookmarkedClass.sessionId ? bookmarkedClass.sessionId : "1",
Expand Down
Loading