-
Notifications
You must be signed in to change notification settings - Fork 4
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
update search #1313
base: main
Are you sure you want to change the base?
update search #1313
Conversation
5502f36
to
062a393
Compare
Netlify Deployments: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Device | URL |
---|---|
mobile | https://ocw-hugo-themes-www-pr-1313--ocw-next.netlify.app/ |
Device | URL |
---|---|
mobile | https://ocw-hugo-themes-www-pr-1313--ocw-next.netlify.app/search/ |
Device | URL |
---|---|
mobile | https://ocw-hugo-themes-course-v2-pr-1313--ocw-next.netlify.app/ |
Not what you expected? Are your scores flaky? GitHub runners could be the cause.
Try running on Foo instead
@@ -71,11 +81,4 @@ function SearchFacet(props: Props) { | |||
) | |||
} | |||
|
|||
const propsAreEqual = (_prevProps: Props, nextProps: Props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use this anymore since the aggregation is no longer nested in the bucket key - but the facets don't appear and disappear so I think the issue has been fixed elsewhere
www/assets/js/lib/constants.ts
Outdated
course_feature_tags: RESOURCE_TYPES, | ||
resource_type: RESOURCE_TYPES | ||
resource_type: ["course"], | ||
department: Object.keys(departments), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a followup pr to get all the options from the generated api documentation
@@ -103,33 +108,60 @@ export const resourceJSONToLearningResource = ( | |||
} | |||
} | |||
|
|||
export const searchResultToLearningResource = ( | |||
result: LearningResourceResult | |||
export const courseSearchResultToLearningResource = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a follow up pr to get rid of the LearningResource type defined in ocw-hugo-themes and update the cards in SearchResult.tsx
to expect the objects returned from the search api directly and update courseJSONToLearningResource and resourceJSONToLearningResource to convert ocw json to CourseResource
and ContentFile
from the open api. It's a little messy since LearningResource
can currently be either a course or a resource but the parameters in CourseResource
and ContentFile
are not the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this is working very well. I've tested:
- filtering
- textual searches
- resource files & courses
- browser navigation (forward/back)
I still need to look at the actual course-search-utils changes.
Changes
-
levelsMap
: Right nowlevelsMap
is constructed fromLearningResourcesListLevelEnum
. This products bad values forhigh_school
andnoncredit
, namely "HighSchool" and "NonCredit" (no space / hyphen).- Maybe just use an explicit mapping like we do for departments?
-
Course links: In the course theme, there are links to the search page using old "Department" and "Level" values
- department appears here: https://ocw.mit.edu/courses/18-102-introduction-to-functional-analysis-spring-2021
- level appears in the course-info box: https://ocw.mit.edu/courses/18-102-introduction-to-functional-analysis-spring-2021/video_galleries/lecture-videos/
In slack we discussed making the search page with both the old and new department/level values, at least temporarily. I think that's reasonable to ease the eventual deployment.
Further checking
Additionally, I think we should:
- Set
CORS_ALLOWED_ORIGIN_REGEXES="ocw-hugo-themes-www-pr-\d+--ocw-next\.netlify"
on MIT Open Prod (if we agree that's OK) - Update the netlify workflow to use MIT Open Prod
That way we can share a version of this that uses the prod search for easier comparison with live OCW.
} from "../lib/constants" | ||
import { emptyOrNil, isDoubleQuoted } from "../lib/util" | ||
import { FacetManifest, LearningResourceResult } from "../LearningResources" | ||
import { FacetManifest } from "../LearningResources" | ||
import { CourseResource, ContentFile } from "../open_api_generated/api" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and elsewhere that you use types only, I would do
import { CourseResource, ContentFile } from "../open_api_generated/api" | |
import type { CourseResource, ContentFile } from "../open_api_generated/api" |
which makes intent clear, and also 100% guarantees there is no impact on runtime.
Also: With the |
b8291a5
to
5cd048a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URLS like http://localhost:3000?d=Mechanical%20Engineering&d=Mathematics&l=High%20School are working great 👍 :
}, | ||
[toggleFacets, activeFacets] | ||
[toggleFacets, activeFacets, endpoint, updateEndpoint, sort, updateSort] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the sort dependency like linter says.
963e8b5
to
26ab8d1
Compare
* move filters to course search util
@ChristopherChudzicki @abeglova what should we do with this PR? I'm not really clear on what it does. |
What are the relevant tickets?
closes #1294
Description (What does it do?)
This pr updates the search to use the new open apis.
It uses the changes to course-search utils from mitodl/course-search-utils#64
How can this be tested?
Run mit-open
Set
COURSE_SEARCH_API_URL=http://localhost:8063/api/v1/learning_resources_search/
CONTENT_FILE_SEARCH_API_URL=http://localhost:8063/api/v1/content_file_search/
Run
yarn start www
Go to http://localhost:3000/search/ and click around. Everything should work as expected. The urls will be a little different than the existing ui