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

Replaces .count and .length with .size in tag model #8435

Merged
merged 3 commits into from
Sep 29, 2020
Merged
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
18 changes: 9 additions & 9 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def path
end

def run_count
self.count = NodeTag.joins(:node).where(tid: tid).where('node.status = 1').count
self.count = NodeTag.joins(:node).where(tid: tid).where('node.status = 1').size
save
end

Expand Down Expand Up @@ -79,7 +79,7 @@ def self.contributors(tagname)

def self.contributor_count(tagname)
uids = Tag.contributors(tagname)
uids.length
uids.size
end

# finds highest viewcount nodes
Expand Down Expand Up @@ -168,7 +168,7 @@ def self.follower_count(tagname)
.collect(&:user_id)
User.where(id: uids)
.where(status: [1, 4])
.count
.size
end

def self.followers(tagname)
Expand Down Expand Up @@ -208,7 +208,7 @@ def weekly_tallies(type = 'note', span = 52)
nids,
(Time.now.to_i - week.weeks.to_i).to_s,
(Time.now.to_i - (week - 1).weeks.to_i).to_s
).count(:all)
).size
end
weeks
end
Expand All @@ -230,7 +230,7 @@ def contribution_graph_making(type = 'note', start = Time.now - 1.year, fin = Ti
nids,
(fin.to_i - week.weeks.to_i).to_s,
(fin.to_i - (week - 1).weeks.to_i).to_s
).count(:all)
).size

weeks[(month.to_f * 1000)] = current_week
week -= 1
Expand All @@ -246,9 +246,9 @@ def quiz_graph(start = Time.now - 1.year, fin = Time.now)
while week >= 1
month = (fin - (week * 7 - 1).days)
weekly_quiz = questions.where(created: range(fin, week))
.count(:all)
.size

weeks[(month.to_f * 1000)] = weekly_quiz.count
weeks[(month.to_f * 1000)] = weekly_quiz.size
week -= 1
end
weeks
Expand All @@ -262,7 +262,7 @@ def comment_graph(start = Time.now - 1.year, fin = Time.now)
while week >= 1
month = (fin - (week * 7 - 1).days)
weekly_comments = comments.where(timestamp: range(fin, week))
.count(:all)
.size

weeks[(month.to_f * 1000)] = weekly_comments
week -= 1
Expand Down Expand Up @@ -360,7 +360,7 @@ def self.tagged_node_count(tag_name)
.includes(:revision, :tag)
.references(:term_data, :node_revisions)
.where('term_data.name = ?', tag_name)
.count
.size
end

def self.related(tag_name, count = 5)
Expand Down