Skip to content

Count all-time stats without where clause #8654

Open
@cesswairimu

Description

@cesswairimu

Following up ##5490 and #8652
The instance variables here

@notes = Node.published.select(%i(created type))
.where(type: 'note', created: @start.to_i..@end.to_i)
.size
@wikis = Revision.published.select(:timestamp)
.where(timestamp: @start.to_i..@end.to_i)
.size - @notes # because notes each have one revision
@people = User.where(created_at: @start..@end).where(status: 1)
.size
@comments = Comment.select(:status, :timestamp)
.where(status: 1, timestamp: @start.to_i..@end.to_i)
.size
@contributors = User.contributor_count_for(@start, @end)
@popular_tags = Tag.nodes_frequency(@start, @end)
total_questions = Node.published.questions
.where(created: @start.to_i..@end.to_i)
@answers = total_questions.joins(:comments).size.size
@questions = total_questions.size.size
end
end

I think this query would be a much faster to do .size on these when the filter is 'all time' stats instead of using the where range clause (where timestamp btn 2010..NOW().

The range currently is

def all_time_stats
params[:start] = Date.new(2014, 01, 01).to_time
params[:end] = Time.now
end

This is the option http://stable.publiclab.org/stats?options=For+all+time

Metadata

Metadata

Assignees

Labels

enhancementexplains that the issue is to improve upon one of our existing features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions