I’m working on a community app that allows the residents of a village to
monitor the traffic going past their houses.
There are multiple locations which have many log entries with a traffic
count and a
I want to let users view a location and see the average vehicles per
day, as well as
the average for a given month.
I’m thinking it won’t be very efficient to run though every log entry
and calculate a
running average every time a user views the statistics page. I’ve never
data in this manner before so I’m not sure the best practice. I suppose
maintain a table with a record for each location. On creation or
modification of a log
entry I could calculate the average and store it there for viewing.
Again, not sure if
I’m heading the right direction.
The second part is calculating average for a give month, or indeed a
year. I could
present the appropriate year/month select box but how can I pull records
relate to the given options?
I could probably pull every single record and compare the entry date to
parameters, then act on it if it fits the time period. Once more I’m
isn’t the most efficient way to proceed.
Grateful for insight on this topic.