Skip to content

Ability to set timeframe for /tag/____ pages #2439

@jywarren

Description

@jywarren

We have these great pages to show activity on a topic:

https://publiclab.org/tag/data-logging

image

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)

screen shot 2018-03-07 at 10 17 08 am

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:

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    HTMLRubybreak-me-upbreak up for cleaner code separation, discrete tests, and, easier and iterative collaborationenhancementexplains that the issue is to improve upon one of our existing featureshelp wantedrequires help by anyone willing to contributemetricshelping to understand our community

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions