Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add graphs for public body statistics #1044

Merged
merged 14 commits into from
Sep 4, 2013
Merged

Conversation

mhl
Copy link
Contributor

@mhl mhl commented Aug 15, 2013

This adds a /body_statistics page which displays graphs like this:

Screenshot of graphs

Currently this page isn't linked to from anywhere - I'd like to try it out on the live site privately before making it public. My reservations about this are:

  • It's too slow to calculate these aggregates on the fly, so there's a rake task to add the summary statistics to new columns on public_bodies. It might be better to have a separate public body statistics table with a one-to-one relationship with public_body just to keep them separate.
  • It could be made easier to override for different installations, but I hope it's OK for a first iteration.

This is used for the calculation of the confidence
intervals for public body statistics.
From the full distribution, this only includes the basic
libary and the component for plotting error bars.
(Flot is MIT licensed.)
Suprisingly, there is not support in base Flot for drawing
axis labels - one solution is to use the flot-axislabels
plugin from:

  https://github.com/markrcote/flot-axislabels

This plugin is also MIT-licensed.
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 0941921 on body-statistics into c2fe6be on rails-3-develop.

@@ -0,0 +1,11 @@
def ci_bounds(pos, n, power)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have a brief comment on what the arguments here are

@crowbot
Copy link
Member

crowbot commented Aug 15, 2013

Can we make the display of this page a feature flag? Happy for this to be merged once that's done.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 75164e9 on body-statistics into c2fe6be on rails-3-develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling bccf104 on body-statistics into c2fe6be on rails-3-develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 49db668 on body-statistics into c2fe6be on rails-3-develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 49db668 on body-statistics into c2fe6be on rails-3-develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 578ee0b on body-statistics into c2fe6be on rails-3-develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 2a70739 on body-statistics into c2fe6be on rails-3-develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 00f7d31 on body-statistics into 821e40d on rails-3-develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 00f7d31 on body-statistics into 821e40d on rails-3-develop.

mhl added 11 commits August 20, 2013 12:11
The statistics on the status of the requests to a particular
public body are too slow to calculate on-the-fly, so this
commit adds:

 * Extra columns on public_bodies to store counts of
   the successful, not held, and overdue request counts
   for each public body.

 * A rake task which should be run periodically to update
   the overdue request count column.

If Javascript is not available, the summary statistics are
shown as tables.  If Javascript is available, graphs are
drawn with Flot.
This adds the MINIMUM_REQUESTS_FOR_STATISTICS config option.
This is as suggested in the Flot documentation.
On PublicBody, we don't need to update info_requests_count
because that's already done with :counter_cache.  On the
other hand, info_requests_successful_count and
info_requests_not_held_count can't be updated easily with
counter_cache (since they need conditions to be attached).
Instead we update them in post_save and post_destroy,
as suggested here:

   http://blog.douglasfshearer.com/post/17495285851/custom-counter-cache-with-conditions

This also adds tests to ensure that the
after_(save|destroy) callbacks are called and that they
modify the counts correctly.
Crockford / JSLint suggests using dot notation for referring
to members of objects where possible.
Move the calculation of statistics on public bodies into
the PublicBody model, so that there's less logic in the
controller.
It seems to be difficult to customize the display of the
tick labels (see the body-statistics-rotated-label branch
for an as-yet-not-working alternative) so for the moment
just reduce the number of public bodies shown per graph
from 10 to 8.
The statistics we're publishing are potentially subject to
misinterpretation, so add some warnings about their experimental
nature.  Also, add a note crediting Mark Goodge for his useful
work on statistics for WhatDoTheyKnow.
We were already excluding graphs where all the data was NULL
but it's possible by directly manipulating the database to
have some values NULL and some non-NULL, so exclude any NULL
values anyway.
@mhl
Copy link
Contributor Author

mhl commented Aug 20, 2013

@crowbot: I've added an option to enable the statistics page (defaulting to false) in b75d79b

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 4656b24 on body-statistics into 821e40d on rails-3-develop.

@mhl mhl deleted the body-statistics branch November 26, 2013 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants