From 2891c6541539656181166710189eb05bf1c8fb13 Mon Sep 17 00:00:00 2001 From: Jacqueline Date: Sat, 14 Dec 2024 02:05:43 -0500 Subject: [PATCH 1/4] Make sorting more intuitive --- client/src/modules/Results/Components/ResultsDisplay.jsx | 9 ++++----- server/src/search/search.controller.ts | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/modules/Results/Components/ResultsDisplay.jsx b/client/src/modules/Results/Components/ResultsDisplay.jsx index f4b7b384..2e996021 100644 --- a/client/src/modules/Results/Components/ResultsDisplay.jsx +++ b/client/src/modules/Results/Components/ResultsDisplay.jsx @@ -11,7 +11,7 @@ import FilterIcon from '../../../assets/icons/filtericon.svg'; import styles from '../Styles/Results.module.css'; /* - ResultsDisplay Component.a + ResultsDisplay Component. Used by Results component, renders filters, list of class objects (results), and PreviewCard. @@ -28,7 +28,7 @@ export default class ResultsDisplay extends Component { courseList: this.props.courses, cardCourse: this.props.courses[0], activeCard: 0, - selected: props.type === 'major' ? 'rating' : 'relevance', + selected: 'relevance', filters: { Fall: true, Spring: true, @@ -249,9 +249,8 @@ export default class ResultsDisplay extends Component { return items.map((result, index) => (
{ // check if query is a subject, if so return only classes with this subject. Catches searches like "CS" const courseSubject = await findCourseSubject(query); if (courseSubject.length > 0) { - return new Set(courseSubject); + return new Set(courseSubject.sort((a, b) => Number(a.classNum) - Number(b.classNum))); } // checks if search is a professor From 5a8b00b26ee7ecb8ca7212f06a0e68f121d48f1d Mon Sep 17 00:00:00 2001 From: Jacqueline Date: Sat, 14 Dec 2024 02:12:29 -0500 Subject: [PATCH 2/4] Sort professor course list --- server/src/search/search.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/search/search.controller.ts b/server/src/search/search.controller.ts index 0f73cae8..2a53fbd5 100644 --- a/server/src/search/search.controller.ts +++ b/server/src/search/search.controller.ts @@ -39,7 +39,7 @@ const fullCourseSearch = async ({ search }: SearchQueryType) => { // returns all courses taught by particular professor const coursesByProfessor = await search.searchQuery(findCourseProfessor); if (coursesByProfessor && coursesByProfessor.length > 0) { - return new Set(coursesByProfessor); + return new Set(coursesByProfessor.sort((a, b) => Number(a.classNum) - Number(b.classNum))); } // check if first digit is a number. Catches searchs like "1100" From 63b4907f54449ec6b8a3d0f1ed5c47aec8c03070 Mon Sep 17 00:00:00 2001 From: Jacqueline Date: Sun, 15 Dec 2024 22:39:35 -0500 Subject: [PATCH 3/4] Add summer semester --- client/src/modules/Results/Components/ResultsDisplay.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/modules/Results/Components/ResultsDisplay.jsx b/client/src/modules/Results/Components/ResultsDisplay.jsx index 2e996021..7b6214da 100644 --- a/client/src/modules/Results/Components/ResultsDisplay.jsx +++ b/client/src/modules/Results/Components/ResultsDisplay.jsx @@ -93,7 +93,8 @@ export default class ResultsDisplay extends Component { 'semesters', new Map([ ['Fall', true], - ['Spring', true] + ['Spring', true], + ['Summer', true] ]) ], ['subjects', []] @@ -138,6 +139,7 @@ export default class ResultsDisplay extends Component { */ sort() { let availableClasses; + if (this.state.filteredItems.length === 0) { availableClasses = this.state.courseList; } else { From a245c5272897dbaca3e59103127acc88aeeda79e Mon Sep 17 00:00:00 2001 From: Jacqueline Date: Thu, 19 Dec 2024 13:13:45 -0800 Subject: [PATCH 4/4] Fix no result rendering --- .../Results/Components/ResultsDisplay.jsx | 159 ++++++++---------- 1 file changed, 71 insertions(+), 88 deletions(-) diff --git a/client/src/modules/Results/Components/ResultsDisplay.jsx b/client/src/modules/Results/Components/ResultsDisplay.jsx index 7b6214da..2b098e80 100644 --- a/client/src/modules/Results/Components/ResultsDisplay.jsx +++ b/client/src/modules/Results/Components/ResultsDisplay.jsx @@ -65,7 +65,7 @@ export default class ResultsDisplay extends Component { { courseList: this.props.courses, relevantCourseList: this.props.courses, - cardCourse: this.props.courses[0] + cardCourse: this.props.courses[0] || null }, () => this.filterClasses() ); @@ -138,13 +138,7 @@ export default class ResultsDisplay extends Component { * Sorts list of class results by category selected in this.state.selected */ sort() { - let availableClasses; - - if (this.state.filteredItems.length === 0) { - availableClasses = this.state.courseList; - } else { - availableClasses = this.state.filteredItems; - } + const availableClasses = this.state.filteredItems; if (this.state.selected === 'relevance') { this.sortBy(availableClasses, 'score', 0, true); @@ -201,7 +195,10 @@ export default class ResultsDisplay extends Component { ); } - this.setState({ filteredItems: filteredItems }, () => this.sort()); + this.setState({ + filteredItems: filteredItems, + cardCourse: filteredItems[0] || null + }, () => this.sort()); } /** @@ -244,9 +241,7 @@ export default class ResultsDisplay extends Component { * The original list as FilteredResult components otherwise */ renderResults() { - const items = this.state.filteredItems.length - ? this.state.filteredItems - : this.state.courseList; + const items = this.state.filteredItems; return items.map((result, index) => (

Search Results

- {/* Case where results are still being loaded */} - {this.props.loading === true && } - {/* Case where no results returned */} - {this.state.courseList.length === 0 && this.props.loading === false && ( -
- No class found -
Sorry! No classes match your search.
-
- )} - {/* Case where results are returned (non-empty) */} - {this.state.courseList.length !== 0 && this.props.loading !== true && ( + {this.props.loading ? ( + + ) : (
-
-
Filter
-
-
Semester
- {this.renderCheckboxes('semesters')} -
-
-
Level
- {this.renderCheckboxes('levels')} -
-
- -
-
- We found{' '} - - {this.state.filteredItems.length === 0 - ? this.state.courseList.length - : this.state.filteredItems.length} - {' '} - courses for "{this.props.userInput} - " + + <> +
+
Filter
+
+
Semester
+ {this.renderCheckboxes('semesters')} +
+
+
Level
+ {this.renderCheckboxes('levels')} +
-
+
- - + We found{' '} + {this.state.filteredItems.length} courses for " + {this.props.userInput}"
- -
- {this.state.showFilterPopup && ( - - )} - -
-
-
-
    {this.renderResults()}
+
+
+ +
+ +
-
- -
+ )} + + {this.state.filteredItems.length !== 0 && ( +
+
+
+
    {this.renderResults()}
+
+
+
+ +
+
+ )}
-
+
)}