-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
We have these great pages to show activity on a topic:
https://publiclab.org/tag/data-logging
However, sometimes we want to be able to see this for a given time period, to understand community growth in that timeframe, kind of like on GitHub Pulse:
https://github.com/publiclab/plots2/pulse/monthly vs.
https://github.com/publiclab/plots2/pulse/weekly
That looks like this (so we may need to set an interface, but for now let's just focus on the pages)
We have these great stats pages where you can set a range: https://publiclab.org/stats/range/10-05-2015/10-05-2016/
The code for that (for example) is:
plots2/app/controllers/stats_controller.rb
Lines 11 to 32 in efc315d
| def range | |
| @start = params[:start] ? Time.parse(params[:start]) : Time.now - 1.month | |
| @end = params[:end] ? Time.parse(params[:end]) : Time.now | |
| @notes = Node.select(%i(created type status)) | |
| .where(type: 'note', status: 1, created: @start.to_i..@end.to_i) | |
| .count(:all) | |
| @wikis = Revision.select(:timestamp) | |
| .where(timestamp: @start.to_i..@end.to_i) | |
| .count - @notes # because notes each have one revision | |
| @people = User.where(created_at: @start..@end) | |
| .joins('INNER JOIN users ON users.uid = rusers.id') | |
| .where('users.status = 1') | |
| .count | |
| @answers = Answer.where(created_at: @start..@end) | |
| .count | |
| @comments = Comment.select(:timestamp) | |
| .where(timestamp: @start.to_i..@end.to_i) | |
| .count | |
| @questions = Node.questions.where(status: 1, created: @start.to_i..@end.to_i) | |
| .count | |
| @contributors = User.contributor_count_for(@start,@end) | |
| end |
Next steps
This could be solved in a few steps, and the first might be to create a new Tag controller action like:
- https://publiclab.org/tag/data-logging?start=16-03-2016&end=14-04-2017 (Add time ranges in tag_controller#show #2618 by @rishabhptr)
- add
weeklyandmonthlybuttons like on GitHub Pulse to show the past week or month - make graphs on tag pages Improved graphs on contributors/tags pages #2619 clickable to go to corresponding timeframe
- add some kind of date selector?

