Skip to content

Commit

Permalink
feat(api): filter by s/u type
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Aug 9, 2023
1 parent ba46f35 commit b5680df
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/api/src/course/course.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ input FilterInput {
"""
genEdTypes: [GenEdType!]

"""
If is `true` or `false` will filter courses by grading method (S/U or Letter Grade)
"""
isSUGrading: Boolean

"""
List of `DayOfWeeks`. This filter is passed IF ANY of the course's sections have class in ANY of the `dayOfWeeks` in the list.
"""
Expand Down
5 changes: 5 additions & 0 deletions apps/api/src/course/course.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class CourseService {
{
keyword = '',
genEdTypes = [],
isSUGrading,
dayOfWeeks = [],
limit = 10,
offset = 0,
Expand All @@ -83,6 +84,10 @@ export class CourseService {
query.genEdType = { $in: genEdTypes }
}

if (isSUGrading !== undefined) {
query.creditHours = isSUGrading ? /S\/U/ : { $not: /S\/U/ }
}

if (dayOfWeeks.length > 0) {
query['sections.classes.dayOfWeek'] = { $in: dayOfWeeks }
}
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class PeriodRangeInput {
export class FilterInput {
keyword?: Nullable<string>;
genEdTypes?: Nullable<GenEdType[]>;
isSUGrading?: Nullable<boolean>;
dayOfWeeks?: Nullable<DayOfWeek[]>;
periodRange?: Nullable<PeriodRangeInput>;
limit?: Nullable<number>;
Expand Down
2 changes: 2 additions & 0 deletions packages/codegen/src/generated/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export type FilterInput = {
dayOfWeeks?: InputMaybe<Array<DayOfWeek>>;
/** List of `GenEdTypes`. This filter is passed IF the course's `genEdType` matches ANY of the `genEdTypes` in the list. */
genEdTypes?: InputMaybe<Array<GenEdType>>;
/** If is `true` or `false` will filter courses by grading method (S/U or Letter Grade) */
isSUGrading?: InputMaybe<Scalars['Boolean']>;
/**
* Keyword to search for courses. This filter is passed IF any of `courseNo`, `abbrName`,
* `courseNameTh`, or `courseNameEn` contains the keyword as a substring (except for `courseNo`
Expand Down

0 comments on commit b5680df

Please sign in to comment.