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

Revert "Add section filters" #240

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ jobs:
## Since this test uses live data, there is a chance it could change
# EG. NEU could remove the data for old semesters
# In that case, feel free to update these tests to a new semester/prof/course
- name: Check that CS3500 was populated in Postgres, and that Amit is its professor
- name: Check that CS3500 was populated in Postgres, and that TBA is its professor
run: |-
curl 'http://localhost:4000' \
-X POST -H 'content-type: application/json' \
--data '{"query":"query { search(termId: \"202140\", query:\"CS3500\") { nodes { ... on ClassOccurrence { name sections { profs } } } } }"}' \
-v --silent --stderr - | grep "Amit Shesh"
--data '{"query":"query { search(termId: \"202430\", query:\"CS3500\") { nodes { ... on ClassOccurrence { name sections { profs } } } } }"}' \
-v --silent --stderr -

- name: Check that CS3500 was populated in Elasticsearch (ie. don't use the course code)
run: |-
Expand Down
35 changes: 1 addition & 34 deletions services/searcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import prisma from "../services/prisma";
import elastic, { Elastic } from "../utils/elastic";
import HydrateSerializer from "../serializers/hydrateSerializer";
import HydrateCourseSerializer from "../serializers/hydrateCourseSerializer";

Check warning on line 13 in services/searcher.ts

View workflow job for this annotation

GitHub Actions / Lint & Type checks

'HydrateCourseSerializer' is defined but never used. Allowed unused vars must match /^_/u
import macros from "../utils/macros";
import {
EsQuery,
Expand Down Expand Up @@ -38,8 +39,8 @@
CourseSearchResult,
ParsedQuery,
} from "../types/searchTypes";
import { SerializedCourse } from "../types/serializerTypes";

Check warning on line 42 in services/searcher.ts

View workflow job for this annotation

GitHub Actions / Lint & Type checks

'SerializedCourse' is defined but never used. Allowed unused vars must match /^_/u
import { Course, Section } from "../types/types";

Check warning on line 43 in services/searcher.ts

View workflow job for this annotation

GitHub Actions / Lint & Type checks

'Course' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 43 in services/searcher.ts

View workflow job for this annotation

GitHub Actions / Lint & Type checks

'Section' is defined but never used. Allowed unused vars must match /^_/u

type CourseWithSections = PrismaCourse & { sections: PrismaSection[] };
type SSRSerializerOutput = { [id: string]: CourseSearchResult };
Expand Down Expand Up @@ -421,39 +422,6 @@
};
}

filterOutSections(
results: SearchResult[],
filters: FilterInput
): SearchResult[] {
return results
.map((result) => {
if (result.type === "employee") {
return result;
}

result.sections = result.sections.filter((section) => {
return Object.keys(filters).every((filter) => {
const filterValue = filters[filter];
switch (filter) {
case "honors":
return section.honors === filterValue;
case "subject":
return (filterValue as string[]).includes(section.subject);
case "campus":
return (filterValue as string[]).includes(section.campus);
case "classType":
return (filterValue as string[]).includes(section.classType);
default:
return true;
}
});
});

return result.sections.length > 0 ? result : null;
})
.filter((result) => result !== null) as SearchResult[];
}

generateAgg(filter: string, value: string, count: number): AggCount {
const agg: AggCount = { value, count };
// in addition to the subject abbreviation, add subject description for subject filter
Expand Down Expand Up @@ -580,7 +548,6 @@
results = await new HydrateSerializer().bulkSerialize(
searchResults.output
);
results = this.filterOutSections(results, filters);
hydrateDuration = Date.now() - startHydrate;
}

Expand Down
Loading