Skip to content

Commit

Permalink
Replaced .count and .length in user model with .size #8206 Issue reso… (
Browse files Browse the repository at this point in the history
#8227)

* Replaced .count and .length in user model with .size #8206 Issue resolved

* Missing surrounding space provided for operator ===
  • Loading branch information
AgyeyaMishra committed Aug 3, 2020
1 parent 3fcb54e commit f6f4a6d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module Frequency
scope :past_month, -> { where("created_at > ?", 1.month.ago) }

def is_new_contributor?
Node.where(uid: id).length === 1 && Node.where(uid: id).first.created_at > 1.month.ago
Node.where(uid: id).size === 1 && Node.where(uid: id).first.created_at > 1.month.ago
end

def new_contributor
Expand Down Expand Up @@ -217,11 +217,11 @@ def photo_path(size = :medium)
end

def first_time_poster
notes.where(status: 1).count.zero?
notes.where(status: 1).size.zero?
end

def first_time_commenter
Comment.where(status: 1, uid: uid).count.zero?
Comment.where(status: 1, uid: uid).size.zero?
end

def follow(other_user)
Expand Down Expand Up @@ -325,11 +325,11 @@ def banned?
end

def note_count
Node.where(status: 1, uid: uid, type: 'note').count
Node.where(status: 1, uid: uid, type: 'note').size
end

def node_count
Node.where(status: 1, uid: uid).count + Revision.where(uid: uid).count
Node.where(status: 1, uid: uid).size + Revision.where(uid: uid).size
end

def liked_notes
Expand Down Expand Up @@ -431,7 +431,7 @@ def contributor_count_for(start_time, end_time)
questions = Node.questions.where(status: 1, created: start_time.to_i..end_time.to_i).pluck(:uid)
comments = Comment.where(timestamp: start_time.to_i..end_time.to_i).pluck(:uid)
revisions = Revision.where(status: 1, timestamp: start_time.to_i..end_time.to_i).pluck(:uid)
contributors = (notes + answers + questions + comments + revisions).compact.uniq.length
contributors = (notes + answers + questions + comments + revisions).compact.uniq.size
contributors
end

Expand Down Expand Up @@ -463,7 +463,7 @@ def count_all_time_contributor
comments = Comment.pluck(:uid)
revisions = Revision.where(status: 1).pluck(:uid)

(notes + answers + questions + comments + revisions).compact.uniq.length
(notes + answers + questions + comments + revisions).compact.uniq.size
end

def watching_location(nwlat, selat, nwlng, selng)
Expand Down

0 comments on commit f6f4a6d

Please sign in to comment.