zooniverse / front-end-monorepo

A rebuild of the front-end for zooniverse.org
https://www.zooniverse.org
Apache License 2.0
104 stars 30 forks source link

Stats state url search param validation #6168

Closed mcbouslog closed 1 week ago

mcbouslog commented 1 month ago

There should be some validation/sanitation on the url search params for stats state - project_id, start_date, and end_date.

When a user enters a url for their user stats page or a group stats page with an invalid stats state search param, what should we do?

  1. We could remove the param and show a simple browser alert noting something like "Invalid project_id included in the url has been removed"
  2. We could remove the param without user notification
  3. Other?

How much validation should we do?

cc: @seanmiller26

seanmiller26 commented 1 month ago

I think we should have a wide-use notification that overlays on the chart. 'No valid projects found(?)' 'No data found for selected date range', etc etc.

But for now, ok to leave current functionality of: Chart shows as empty when incorrect project or date range is selected.

goplayoutside3 commented 1 month ago

Agreed with Sean the barchart area can utilize a "no data for this project and/or date range" state. For the url itself, if someone manually enters an invalid project id or date range, I don't think we should modify the url, and instead we'll just handle the messaging in the presentational components. There should be no data fetching with an invalid project id or date range though. @mcbouslog thoughts on that?

goplayoutside3 commented 1 month ago

To answer your question

How much validation should we do?

project_id

dates

For instance, data fetching should only occur when the above validations are true, and then if the data fetching functions don't return any stats, utilize a "no data for this project and/or date range" state in the barchart ( which can be the same barchart state if any validation fails, too ).

trouille commented 1 month ago

Need to ensure that you can't have dates earlier than March 17, 2015 in the URL (since can't pull data prior to this date)