mroswell / vaxscience

0 stars 1 forks source link

Plugin to remove unwanted Suggested Facets #5

Open mroswell opened 2 years ago

mroswell commented 2 years ago

By default, Datasette is offering these suggested facets in the following order.

Main_Topic, Title, Link(s), Demographics, Abstract, MeSH, Author(s), Affiliation, PMID, PMCID, PubDate, article_title, Section, Subsection, PubType, PubDate (date), Main_Topic (array), Demographics (array), MeSH (array), Author(s) (array), Affiliation (array)

Replace this with Main_Topic, Demographics, MeSH, Author(s), Section, Subsection, PubType

there may be some model code (though by a relative newbie coder) here: https://github.com/mroswell/list-N/tree/main/plugins or https://datasette.io/plugins

mroswell commented 2 years ago

Hmmm... maybe a plugin isn't needed. I need to get to know this issue: https://github.com/simonw/datasette/issues/1552

nsmgr8 commented 2 years ago

You need to use a metadata.json and list which fields you want facets for. See https://docs.datasette.io/en/stable/metadata.html and https://docs.datasette.io/en/stable/facets.html#facets-in-metadata-json

mroswell commented 2 years ago

You need to use a metadata.json and list which fields you want facets for. See https://docs.datasette.io/en/stable/metadata.html and https://docs.datasette.io/en/stable/facets.html#facets-in-metadata-json

This does not yield the desired behavior.

  1. It does not exclude the unwanted fields from suggested facets.
  2. It does not exclude the aggregated version of the field, so in addition to getting the desired disaggregated array, it also includes a second copy of the field in the List format like this: ["COVID-19 Vaccines", "COVID-19", "Pulmonary Eosinophilia"]
  3. It opens the suggested facet by default.
  4. The extraneous word "(Array)" appears next to the field name.

I added a metadata.json file, so if you can fire up Datasette you'll see this behavior. I'm pretty sure a plugin is needed.

nsmgr8 commented 2 years ago

You can put all the fields that you want to be suggested and then turn off facets using config.

datasette articles.db --metadata metadata.json --config suggest_facets:off

mroswell commented 2 years ago

With suggest_facets:off, we get:

---- AFTER:

Screen Shot 2022-06-16 at 9 48 49 AM

---- BEFORE:

Screen Shot 2022-06-16 at 9 48 38 AM

So, despite implementing all of the above, still not getting the behavior I'm seeking. I want to give the user access to selected facets.

(Note that with the solution above, there is no ability to turn off the long list of Main_Topics, or any other facets I decide to add)

nsmgr8 commented 2 years ago

See the pull-request for a fix for this.