seven1m/onebody

.count vs .size

lelelelemon opened this issue · 1 comments


onebody/app/models/family.rb:201:    if adults.count == 1
onebody/app/models/family.rb:203:    elsif adults.count >= 2
onebody/app/models/import.rb-50-    return 0 if row_count.to_i == 0
onebody/app/models/import.rb:51:    (completed_rows_in_stage.count * 100 / row_count).round
onebody/app/controllers/administration/dashboards_controller.rb-8-    @email_changed_count = Person.email_changed.count
onebody/app/controllers/administration/dashboards_controller.rb:10:    @import_errors_count = @last_import ? @last_import.rows.errored.count : 0
onebody/app/controllers/administration/dashboards_controller.rb-11-    @groups_pending_approval_count = Group.unapproved.count
onebody/app/controllers/administration/dashboards_controller.rb-12-    @membership_request_count = MembershipRequest.count
onebody/app/controllers/verses_controller.rb:61:    if @verse.people.count == 0
onebody/app/controllers/pictures_controller.rb:19:    if @albums.count == 0
onebody/app/controllers/accounts_controller.rb:132:    if @verification.people.count > 1

.count whatever will issue a query but when the array is loaded, use .size is faster than .count

@lelelelemon PRs are welcome. I'll merge if you'll make the PR. Thanks.