fspc / Yellow-Bike-Database

Yellow Bike Project Hours and Transaction Database for Community Bike Shops
GNU General Public License v3.0
7 stars 1 forks source link

Defeating the 24hr shop logic creates weird results #38

Closed fspc closed 6 years ago

fspc commented 6 years ago

YBDB assumes a shop opens and closes within a 24hr period (0 - 24), however if a shop if opened after 0 (12 am), and someone logs in before 0, then weird things happen:

  1. current time disappears from the Time In pulldown (just like a closed shop)
  2. hours for volunteering are no longer calculated correctly, so 3 hours of volunteering (10pm to 1am) becomes 21 hours of volunteering

Test this by creating a shop before 0 to find out if same situation exists, since late night shops have been unusual.

fspc commented 6 years ago

The results for a shop created before 0 with hours after 24 were the same as beginning a shop after 0 with hours dialed back before 0.

new vol: 1hr 23 extra, 2hr 22 extra, 3hr 21 extra, 4hr 20extra, 5hr 19 extra .. 8hr 16 extra existing vol: 1hr 22 extra, 2hr 21 extra .. 8hr 16 extra (seemed skewed 1hr + after closing for testing)

ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS current_year_volunteer_hours

in the volunteer_benefits json call in transaction.php are where these answers are coming from; incorrect hours are coming from the same mysql statement in start_shop.