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

[Package][Genetics] Fix search for Genetics #356

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

Conversation

riyavsinha
Copy link
Contributor

Current state of search for genetics:

Screenshot 2024-03-23 at 8 17 38 PM

Description

First issue was that there were no default searchSuggestions for the genetics app provided in the SearchContext, so mapping over the undefined object caused errors. This was fixed by making the default searchSuggestions an empty array. Also, I only now render the suggestions element + header when searchSuggestions is non-empty.

The second issue is that it seems the routing logic was only written/updated for the Platform and not Genetics? The searchUtils data formatting for Genetics turns the entity types into genes, variants or studies, which cause bad urls that do not work. Using __typeName to lowercase does work for now. This does not affect the Platform because the Platform search results use the value.hits array style. Additionally, the useListOption URL construction adds on /associations for gene and variant type entities, and requires a studyId for studies which is not present in the Genetics application study entities it seems. I have modified that code to account for that for now.

However, I believe a better longer term solution would be for each application to pass in an entityToUrlMapper function to the useListOption hook, since that hook is supposed to be application-agnostic.

Issue: # (link)
Deploy preview: (link)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • Manual test genetics
  • Manual test platform

New state for genetics:

Screenshot 2024-03-23 at 8 27 33 PM Screenshot 2024-03-23 at 8 27 44 PM Screenshot 2024-03-23 at 8 27 58 PM

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@carcruz
Copy link
Contributor

carcruz commented Apr 30, 2024

Thank you @riyavsinha 👍 @chinmehta will be taking a look at the code during the week

@@ -13,15 +13,19 @@ function useListOption() {
if (newOption.entity === "search") {
history.push(`/search?q=${newOption.name}&page=1`);
} else if (newOption.entity === "study") {
history.push(`/${newOption.entity}/${newOption.studyId}`);
if (newOption.studyId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

at this point we should use switch instead of if conditional statements

if (isArray(value)) {
value.map(i =>
typesArray.push({
type: key === "topHit" ? "topHit" : key,
entity: key,
type: key === "topHit" ? "topHit" : i.__typename.toLowerCase(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Apollo primarily provides __typename for its own functions like caching, we should try to use the response that is present in the schema.

</Box>
);
const SearchSuggestionEl =
searchSuggestions.length > 0 ? (
Copy link
Contributor

@chinmehta chinmehta May 9, 2024

Choose a reason for hiding this comment

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

It is good to have a condition, although it is preferred that we modify and pass EXAMPLES from Genetics > HomePage.tsx so that we don't see empty search container.

Copy link
Contributor

@chinmehta chinmehta left a comment

Choose a reason for hiding this comment

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

Comments added

@chinmehta chinmehta added the community Open source contributions from community label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Open source contributions from community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants