azavea / ism-watershed-wellness-snapshot

A tool to collect and display watershed wellness indicators for the International Seaport Museum
1 stars 2 forks source link

Display dynamic timestamp in footer #71

Closed fungjj92 closed 5 years ago

fungjj92 commented 5 years ago

Overview

The footer now displays a real value for time since last and latest data update. ~Time is displayed as days, hours, or minutes based on what seems sensible. I didn't consider the next jump up which is months, but I can add that 🤔Since sensors haven't been updating real-time as hoped for the app despite data being polled every 10 minutes, the timestamp is as of now kind of a let down 😢 ~ Edit: Display a time indicator that is appropriate for the time elapsed. The longer the time frame, the softer the messaging.

Connects #42

Demo

Using default data: screen shot 2019-03-05 at 5 24 35 pm

Using live sensor data: screen shot 2019-03-05 at 5 25 02 pm

Notes

~I was ambivalent between putting the logic in App.js vs Footer.jsx. I don't think it matters too much, however if you have a strong argument to move the logic to the Footer, I will consider.~ Moved to utils, makes sense in retrospect.

Testing Instructions

Netlify should suffice.

fungjj92 commented 5 years ago

@alexelash weighed in on this and agrees the timestamp has become a little disappointing. She's gonna run this through design crit. Perhaps static generic text after X time instead of a true count.

alexelash commented 5 years ago

@fungjj92 here is an updated list that will (hopefully!) be straightforward but less disappointing-sounding: < 1 hour ago = Health reading updated X {minutes} ago > 12am today = Health reading updated today. 
> 12am yesterday = Health reading updated yesterday. > 12am 2 days ago = Health reading updated in the past week. > 1 week ago = Health reading updated in the past month.
 > 1 month ago = Health reading updated in the past year.
 > 1 year ago = Health reading updated over a year ago. no data = [default to “common” reading & copy] Common sensor readings displayed for each site.

fungjj92 commented 5 years ago

Just pushed up changes. Good call adding a test -- the act of writing tests had me fill in and correct missing conditions for timestamp labels, incorrect constants (math is hard), and also fix the tests that were broken anyway from #63, which added a timestamp field to sensorData items.

Speaking of, tests don't run on cibuild but that would be helpful. I'm investigating and will make a separate card.