bikebrigade / dispatch

Bike Brigade's dispatching software! 🚴
https://bikebrigade.ca
Apache License 2.0
74 stars 9 forks source link

Decouple program_stats from campaign_stats #87

Open mveytsman opened 2 years ago

mveytsman commented 2 years ago

Currently the campaign stats view is giving us a count of campaigns for a program, by using ROLLUP. We should instead have a program stats view that counts campaigns (among other things).

It could even join with the the campaign stats view and do aggregates across all the programs campaigns.

sereprz commented 2 years ago

@mveytsman can you link me to the current sql?

mveytsman commented 2 years ago

This TODO may also be related https://github.com/bikebrigade/dispatch/blob/main/lib/bike_brigade/stats.ex#L171-L173

mveytsman commented 2 years ago

@sereprz see https://github.com/bikebrigade/dispatch/blob/804f743d32be63ad317af2de2a87c29dcf09751a/priv/repo/sql/campaign_stats_view.sql and especially this diff.

In the diff you see I half solved this ticket - I took out the rollup / campaigns per program count from the view. Now we just don't get the stat from anywhere (that diff comments out displaying program.campaign_count).

I think it would be useful to have a program stats view, but it needs to be scoped out.

This TODO may also be related https://github.com/bikebrigade/dispatch/blob/main/lib/bike_brigade/stats.ex#L171-L173 This was about a different stats view - riders not campaigns. We can scope out an issue here also if/when you have time.