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

Dynamic error cdi; COUNTRY=jordan #1259

Merged
merged 10 commits into from
Jul 3, 2024
Merged

Conversation

lowriech
Copy link
Collaborator

@wadhwamatic check it out, pretty simple updates to parameterize a local hip service and to utilize a detail error message

@lowriech
Copy link
Collaborator Author

Goes with: https:/WFP-VAM/hip-service/pull/11

Copy link

github-actions bot commented May 29, 2024

Build succeeded and deployed at https://prism-1259.surge.sh
(hash d61911f deployed at 2024-07-02T18:23:29)

README.md Outdated Show resolved Hide resolved
@ericboucher ericboucher changed the base branch from master to cdi-range-update May 29, 2024 15:12
@wadhwamatic
Copy link
Member

@lowriech - the date error message correctly appears when the latest date (11-May) is requested. But subsequent requests are not rendering when data is available even though the response is the expected geojson object. It would also be good to test this and #1253 together.

@lowriech
Copy link
Collaborator Author

@wadhwamatic I'm not seeing the error where "subsequent requests are not rendering when data is available even though the response is the expected geojson object". Can you clarify?

Merged in range update PR to this PR.

@wadhwamatic
Copy link
Member

@lowriech - what I meant is:

  1. If you request CDI on a date that doesn't have data, you see the error message you created
  2. But if you make a second request one another date which does have CDI data, the geojson response is not rendered on the map even though I see in the dev console that the object was returned
  3. It seems that the first error prevents a subsequent valid request from rendering

@lowriech
Copy link
Collaborator Author

lowriech commented Jun 4, 2024

Can you send the environment you're using to look at this? That's not what I see, I have updates as usual after the error. @wadhwamatic

@wadhwamatic
Copy link
Member

wadhwamatic commented Jun 18, 2024

@lowriech - I assigned two issues to @paololucchino to 1) modify the error message text and 2) to create an endpoint for available dates before a CDI layer is loaded.

What we have so far works, but is less than ideal since a user has no idea what dates are going to be valid. I'm wondering for now if we should just hack this a bit and assume the latest available CDI will be today - 1 month.

@ericboucher, what do you think about this approach given that we don't have a way to know available dates for CDI as of now. If this sounds good, maybe @gislawill can take on implementation.

@ericboucher ericboucher changed the title Dynamic error cdi Dynamic error cdi; COUNTRY=jordan Jun 19, 2024
@ericboucher
Copy link
Collaborator

@wadhwamatic can you share a case where the data is not available for CDI?

README.md Outdated Show resolved Hide resolved
@wadhwamatic
Copy link
Member

@wadhwamatic can you share a case where the data is not available for CDI?

@ericboucher - Jordan CDI on 1-June-2024 returns a date error. https://prism-1259.surge.sh/?hazardLayerIds=cdi_v1&date=2024-06-01

Screenshot 2024-06-19 at 08 14 27

@gislawill gislawill self-assigned this Jun 25, 2024
@gislawill
Copy link
Collaborator

@wadhwamatic, @lowriech, @ericboucher — I've made an attempt to improve this and would appreciate your thoughts. The latest available date for analysis currently is May 1st (exactly two months ago). To hack this before WFP-VAM/hip-service#12, I added an "expectedDataLagDays" option to the composite layer that shifts the default date.

Currently, the default date is the latest available date that that's returned from the server as SPI's latest available date.
This update, adds an expected lag of 55 days so the latest available date is the latest date returned from the server as SPI's latest available date and is more then 55 days in the past
After WFP-VAM/hip-service#12, this date should come from the backend and we can remove this logic

Comment on lines 30 to 31
// TODO - use getPossibleDatesForLayer
// Update on 2024-07-01: getPossibleDatesForLayer would give us the first possible layer date, we want the _last_ possible date.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note here, I don't think this to do is still relevant. Either that or we should refactor how composite layers are handled in getPossibleDatesForLayer

@wadhwamatic
Copy link
Member

wadhwamatic commented Jul 2, 2024

@gislawill - thanks for diving into this. The logic you described below all sounds good to me for our temporary solution until hip-service handles date availability.

Currently, the default date is the latest available date that that's returned from the server as SPI's latest available date.
This update, adds an expected lag of 55 days so the latest available date is the latest date returned from the server as SPI's latest available date and is more then 55 days in the past
After WFP-VAM/hip-service#12, this date should come from the backend and we can remove this logic

Ideally, we would also use the date lag definition to hide unavailable dates in the timeline. In this case, we'd want to show available date ticks that are more than 55 days in the past for the CDI layer. But if that is going to add a lot of extra work, we can skip it for now.

@gislawill
Copy link
Collaborator

@wadhwamatic sure thing, I added that update here: #1295

I separated it from this PR because I'm not confident the improvement in user experience is worth the risk of bugs + complications to maintainance we'd be introducing. If https:/WFP-VAM/hip-service/issues/12 is coming soon and this UX improvement, I believe that solution (in #1295) is functional and addresses the issue. It's just pretty unintuitive code so I wouldn't want it in the codebase for now

@gislawill
Copy link
Collaborator

Heads up, after discussing with Amit, I pulled all of my commits from this branch to #1295

That allows it to be used for demos without adding this date logic complication to the repo

@gislawill
Copy link
Collaborator

This should be ready for review again @wadhwamatic and @ericboucher

@ericboucher
Copy link
Collaborator

ok to merge into the other PR but I would prefer to remove the REACT_APP_USE_LOCAL_HIP_SERVICE logic before merging to main

@ericboucher ericboucher merged commit f078b81 into cdi-range-update Jul 3, 2024
6 checks passed
@ericboucher ericboucher deleted the dynamic-error-cdi branch July 3, 2024 15:30
gislawill added a commit that referenced this pull request Jul 29, 2024
* Updating to use month range

* Fix date propagation in CDI

* Update composite_data.ts

* Use getFormattedDate

* Update composite_data.ts

* Update composite_data.ts

* add mozambique cdi for testing

* Update index.tsx

* Dynamic error cdi; COUNTRY=jordan (#1259)

* Updating to use local hip service

* no console

* Clean up

* Clean up readme

---------

Co-authored-by: Christopher J Lowrie <[email protected]>
Co-authored-by: ericboucher <[email protected]>
Co-authored-by: Amit Wadhwa <[email protected]>
Co-authored-by: Will Gislason <[email protected]>

* Removing local hip service env var

* Error handling fixes and end date support form the lyer

* Initial support for seasonal CDI

* Remove console log, update configs for tests to pass

* Appease eslint

* Fixing seasonal fetch - using first of next season as 'end'

* Support for validity areas in composite layers

* Reducing date deduping

* Clean up

* refactor datesAreEqualWithoutTime

* Fix datesAreEqualWithoutTime

* Adding 'season' validity

* Skip the tests

* Fixing query date for seasonal range

* Updating CDI config in cambodia and mozambique

* Update tests

* undo log update

* update mozambique CDI for testing

* Update composite monthly date range

* Handling overlap selection for dates without overlapping validity

* fix test

* rename scale to period

* Updates to date picking

* Allow composite layers with validity or without

* Update the query display matching to be more flexible

* Updating event handlers in time selection

* Test fic

* Better test fix

* Break out visible layer dates and selectable layer dates

* don't fetch CDI for invalid dates

* fix tests

* Fixing availability date indicator

* Ensuring messaging fires

* fix lint

* Reuse clickDate for draggable item

* Update index.tsx

* Update datasetStateSlice.ts

* Update index.tsx

* Adding back no date overlapping handling

* Ensuring that date selection warning is displayed when the date jumps to valid date

* Remove check intersection, leveraging logic in layer-utils

* using in datesAreEqualWithoutTime in findDateIndex

* Update layers-utils.tsx

* Only remove non-boundary layers

* Handling AA dates with fewer limitations

* Add comment to code

* Fix extra visible dates for AA

* Update logic in useLayer's useEffect to ensure we don't exit early

* Fix AA parseFloat

* Ensuring group is writable in formatLayersCategories

* fixing eslint

---------

Co-authored-by: Christopher J Lowrie <[email protected]>
Co-authored-by: ericboucher <[email protected]>
Co-authored-by: Amit Wadhwa <[email protected]>
Co-authored-by: Chris Lowrie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants