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

added total contributors for all time #3695

Merged
merged 4 commits into from Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,8 @@ def index

@all_notes = nids.uniq.length
@all_contributors = users.uniq.length
Rails.cache.fetch("total-contributors-all-time", expires_in: 1.weeks) do
@all_time_contributors = User.count_all_time_contributor
end
end
end
9 changes: 9 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,13 @@ def self.create_with_omniauth(auth)
user.save!
end
end

def self.count_all_time_contributor
notes = Node.where(type: 'note', status: 1).pluck(:uid)
answers = Answer.pluck(:uid)
questions = Node.questions.where(status: 1).pluck(:uid)
comments = Comment.pluck(:uid)
revisions = Revision.where(status: 1).pluck(:uid)
contributors = (notes + answers + questions + comments + revisions).compact.uniq.length
end
end
2 changes: 2 additions & 0 deletions app/views/stats/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

<h4><%= raw t('notes.stats.research_notes_posted_by_contributors', :note_count => @all_notes, :contributors_count => @all_contributors,
:time => time_ago_in_words(Node.find_by(type: 'note', status: 1).created_at)) %></h4>
<h4><%= raw t('notes.stats.total_contributors', :all_contributors_count => @all_time_contributors) %></h4>

<p><%= raw t('notes.stats.notes_per_week_past_year', :note_count => @notes_per_week_past_year.round(2)) %></p>

<p><i><%= t('notes.stats.note_posting_52_weeks') %></i></p>
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/notes/stats/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ en:
and <a href='%{url2}'>%{wiki_count} wiki edits</a> posted in the past month.
people_joined_past_month: "<b>%{people_count} people</b> joined in the past month."
research_notes_posted_by_contributors: "%{note_count} research notes have been posted by %{contributors_count} contributors since %{time} ago"
total_contributors: "%{all_contributors_count} Total Contributors (Tallied weekly)"
notes_per_week_past_year: "%{note_count} notes per week over the past year."
note_posting_52_weeks: "Note posting for the past 52 weeks:"
wiki_pages_posted: "%{count} wiki pages have been posted, total"
Expand Down