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

update search #1313

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

update search #1313

wants to merge 2 commits into from

Conversation

abeglova
Copy link
Contributor

@abeglova abeglova commented Feb 9, 2024

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

@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 12:49 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 12:50 Inactive
Copy link

github-actions bot commented Feb 9, 2024

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 13:09 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 13:09 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 13:37 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 13:38 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 15:12 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 15:12 Inactive
@@ -71,11 +81,4 @@ function SearchFacet(props: Props) {
)
}

const propsAreEqual = (_prevProps: Props, nextProps: Props) => {
Copy link
Contributor Author

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

course_feature_tags: RESOURCE_TYPES,
resource_type: RESOURCE_TYPES
resource_type: ["course"],
department: Object.keys(departments),
Copy link
Contributor Author

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 = (
Copy link
Contributor Author

@abeglova abeglova Feb 9, 2024

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

@abeglova abeglova changed the title updates search update search Feb 9, 2024
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 15:57 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 15:57 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 16:01 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 9, 2024 16:01 Inactive
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a 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

  1. levelsMap: Right now levelsMap is constructed from LearningResourcesListLevelEnum. This products bad values for high_school and noncredit, namely "HighSchool" and "NonCredit" (no space / hyphen).

    • Maybe just use an explicit mapping like we do for departments?
  2. Course links: In the course theme, there are links to the search page using old "Department" and "Level" values

    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:

  1. Set CORS_ALLOWED_ORIGIN_REGEXES="ocw-hugo-themes-www-pr-\d+--ocw-next\.netlify" on MIT Open Prod (if we agree that's OK)
  2. 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"
Copy link
Contributor

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

Suggested change
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.

@ChristopherChudzicki
Copy link
Contributor

Also: With the levelsMap change, I think you're only using types from the generated code. We could move that generated code to course-search-utils, and just export the relevant types from there. (With the goal that the generated could in course-search-utils should be replaced via mitodl/open-api-cleints soon.)

@github-actions github-actions bot temporarily deployed to pull request February 13, 2024 14:47 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 13, 2024 14:48 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 13, 2024 16:27 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 13, 2024 16:27 Inactive
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
[toggleFacets, activeFacets]
[toggleFacets, activeFacets, endpoint, updateEndpoint, sort, updateSort]
Copy link
Contributor

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.

@github-actions github-actions bot temporarily deployed to pull request February 14, 2024 18:16 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 14, 2024 18:16 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 14, 2024 18:46 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 14, 2024 18:47 Inactive
* move filters to course search util
@pdpinch
Copy link
Member

pdpinch commented Sep 10, 2024

@ChristopherChudzicki @abeglova what should we do with this PR? I'm not really clear on what it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the ocw search page to use the new search apis
3 participants