mysociety/planningalerts-app — pull request #74 by lizconlan (2014-10-10 09:52:09+00:00)
Title: Issues/68 stats data

WIP

Pulls in decision date, status (Approved, Refused, In Progress) and overdue from the planning hub data.

Decision date and target date (needed to calculate whether something is/was overdue) are not always available (TODO: more investigation into whether this seems to occur within specific subsets of the data i.e. deferred decisions?)

Passes the breakdown of Approved / Refused / In Progress through to the search controller (via a search facet) - filtering on that facet is available but once a filter is in effect, the breakdown is lost so in practice this may not be useful.

Performs the percentage calculations - please note, due to the data being incomplete the % overdue may be an underestimate (if comparing councils this may unfairly favour those that supply less complete data) in the authorities#index view. If we're going to keep that display it's probably worth pulling the code for that into a helper function.

At the moment the "stats" are just in the Application model. While this works well for displaying information on the results page - and doesn't appear to be too bad for the authority list - incremental updates could be problematic and it doesn't lend itself well to more complex calculations or future extensibility.

If we split the stats out into a separate table, we should consider whether we want to just hold all-time stats or have a more complex structure which will allow us to do monthly/annual/past x month cuts of the data.