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

Fix display name and unexpected behaviour on Biome filters #121

Open
lukepereira opened this issue Sep 20, 2024 · 0 comments
Open

Fix display name and unexpected behaviour on Biome filters #121

lukepereira opened this issue Sep 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lukepereira
Copy link
Contributor

Describe the bug

I set up some of the configs to support biome filters using the table but some issues will still need to be resolved

  1. The names being displayed show WWF codes (WWF_TEW_BIOME_*) instead of the human readable names (Tundra).
  2. After applying a biome filter, points on the map of different biomes appear.

Expected behavior

  1. Display human readable names instead of WWF codes
  2. After applying a biome filters, only show points on the map related to filtered biome

Steps to reproduce

Open filters and apply biome filter.

Modules involved

  • Query builder
  • Ecology module

System information

No response

Additional context

It would be better to include the human readable name in the materialized view instead of mapping it on the frontend. This is because the filters are stored in app state and having the same value for display text and sql value would be consistent with behaviour of all other filters.

I'm not sure if the materialized view is easy to update, but I started drafting what the query would be:

CREATE MATERIALIZED VIEW IF NOT EXISTS public.bgl_gm4326_gp4326
TABLESPACE pg_default
AS
 SELECT biosample_geographical_location.accession,
    biosample_geographical_location.attribute_name,
    biosample_geographical_location.attribute_value,
    biosample_geographical_location.lat_lon,
    biosample_geographical_location.palm_virome,
    bgl_ll_3_gm4326_gp4326.gm4326_id,
    bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id,
    CASE
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_01' THEN 'Tropical & Subtropical Moist Broadleaf Forests'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_02' THEN 'Tropical & Subtropical Dry Broadleaf Forests'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_03' THEN 'Tropical & Subtropical Coniferous Forests'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_04' THEN 'Temperate Broadleaf & Mixed Forests'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_05' THEN 'Temperate Conifer Forests'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_06' THEN 'Boreal Forests/Taiga'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_07' THEN 'Tropical & Subtropical Grasslands, Savannas & Shrublands'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_08' THEN 'Temperate Grasslands, Savannas & Shrublands'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_09' THEN 'Flooded Grasslands & Savannas'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_10' THEN 'Montane Grasslands & Shrublands'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_11' THEN 'Tundra'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_12' THEN 'Mediterranean Forests, Woodlands & Scrub'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_13' THEN 'Deserts & Xeric Shrublands'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_14' THEN 'Mangroves'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_98' THEN 'Ocean'
      WHEN bgl_ll_3_gm4326_gp4326.gp4326_wwf_tew_id = 'WWF_TEW_BIOME_99' THEN 'Ocean'
    ELSE 'N/A'
    END AS biome_name
   FROM biosample_geographical_location
     LEFT JOIN bgl_ll_3_gm4326_gp4326 ON biosample_geographical_location.attribute_value = bgl_ll_3_gm4326_gp4326.attribute_value
WITH DATA;
@lukepereira lukepereira added the bug Something isn't working label Sep 20, 2024
@github-project-automation github-project-automation bot moved this to Backlog in Open Virome Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant