-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
@@ -0,0 +1,11 @@ | |||
def ci_bounds(pos, n, power) |
There was a problem hiding this comment.
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
Can we make the display of this page a feature flag? Happy for this to be merged once that's done. |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a
/body_statistics
page which displays graphs like this: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:
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.