inato / inato-anticovid

Inato's contribution to the fight against COVID19
https://covid.inato.com
MIT License
3 stars 1 forks source link

As a user, I can see suggestions of search #121

Closed brunovegreville closed 4 years ago

brunovegreville commented 4 years ago

A suggestion is

For instance, a suggestion could be

Using a suggestion replaces all filters of the search by the ones specified by the suggestion.

Suggestion is a way for us to indicate interesting search to the users, and educate him on how the search works. These suggestions will change over time based on the promising leads in clinical research. Ideally, product team can add/edit and remove suggestions without the intervention of the app team.

You can see in the Figma specs how they would be integrated in our platform ⚠️ The front-end specs might change a bit today, so please focus the analysis on the back-end and domain modeling vs. jumping directly in the UI 🙏

gabsn commented 4 years ago

Analysis

To control the state of the controlled Algolia widgets, we can use their attribute defaultRefinement.

See Algolia doc.

For example if you want to select those 3 facets: image

The searchState looks like:

{
  "recruitment_status": [
    "Recruiting"
  ],
  "therapeutic_classes": [
    "Antiviral",
    "Traditional medicine"
  ]
}

What I propose is to store the suggestions as the following JSON:

{
   "suggestions": [
      {
         "name": "toto",
         "recruitment_status":[
            "Recruiting"
         ],
         "therapeutic_classes":[
            "Antiviral",
            "Traditional medicine"
         ]
      },
      {
         "name": "tata",
         "recruitment_status":[
            "Not Recruiting"
         ]
      }
   ]
}

To ease operations, I propose to store this JSON file in Firebase Cloud Firestore. It should be easily updatable by the product team. We could also use an easier to use service like LaunchDarkly or even consider use Algolia, but it is an anti-pattern.

The UI would fetch this JSON at mount time and dynamically mount the suggestions buttons that when clicked on would update the search state.

When product would like to update them, they’ll just have to connect to the firebase console. image

gabsn commented 4 years ago

Dev Breakdown