Orcasa-Platform / orcasa

A Horizon Europe project to restore soil earth
https://orcasa-client.vercel.app
MIT License
2 stars 0 forks source link

Show practices with main intervention = None by default #288

Closed Bluesmile82 closed 7 months ago

Bluesmile82 commented 7 months ago

Allow the Main interventions = None to be shown by default on Practices. These wont show if we have a Main intervention selected. On local and staging I haven't found how to Publish a Practice with Main intervention = None so to test use: NEXT_PUBLIC_API_URL=https://demo.orcasa.dev-vizzuality.com/cms/api/

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orcasa-client ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 0:31am
clementprdhomme commented 7 months ago

While the change you did fixed the query when there is no filter, it breaks the queries when we do have filters.

For example, if I select “Wetlands” as a land use type, here is the shape of the query:

AND
 [0]
   OR
     [0]
       AND
         [0] intervention = None
     [1]
       AND
         [0] intervention = Management
         [1]
           OR
             [0] land use type = Wetlands
     [2]
       AND
         [0] intervention = Land Use Change
         [1]
           OR
             [0] land use type = Wetlands
     [3]
       AND
         [0] intervention = Land Use Change
         [1]
           OR
             [0] land use type = Wetlands

What you can see is that we're loading all the practices for which the intervention is “None”, which doesn't match our definition of the filter in the truth table.

You'll also notice that the 4th part of the top-level OR condition is a duplicate of the third. That bug was already present before you made your changes.

I think that instead of introducing a condition based on the “None” value, we should not filter by intervention if none is selected.