Skip to content

Commit

Permalink
Revert "Add section filters (#234)"
Browse files Browse the repository at this point in the history
This reverts commit 561f7ea.
  • Loading branch information
ananyaspatil authored Nov 10, 2024
1 parent 561f7ea commit 8e8efee
Showing 1 changed file with 1 addition and 34 deletions.
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 {
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 @@ -421,39 +422,6 @@ class Searcher {
};
}

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 @@ class Searcher {
results = await new HydrateSerializer().bulkSerialize(
searchResults.output
);
results = this.filterOutSections(results, filters);
hydrateDuration = Date.now() - startHydrate;
}

Expand Down

0 comments on commit 8e8efee

Please sign in to comment.