Skip to content

Commit

Permalink
Adjusting strand.rb find_by_member methods to correct cc_question N+1…
Browse files Browse the repository at this point in the history
… issue
  • Loading branch information
Charles De Barros committed Feb 7, 2019
1 parent 3c0b0c8 commit 584bdf5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/response_domain_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ResponseDomainCode < ApplicationRecord
#
# @return [Array] List of codes as hashes
def codes
self.code_list.codes.map do |x|
self.code_list.codes.includes(:code_list).map do |x|
{
label: x.category.label,
value: x.value,
Expand Down
6 changes: 3 additions & 3 deletions app/models/strand.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def self.find(id)
# @return [Strand]
def self.find_by_member(member)
begin
id = redis.hget LOOKUP, member.typed_id
@id ||= redis.hget LOOKUP, member.typed_id
rescue Redis::CannotConnectError
Rails.logger.warn 'Cannot connect to Redis'
end
return nil if id.nil?
return Strand.find(id.to_i)
return nil if @id.nil?
return Strand.find(@id.to_i)
end

# Rebuilds all Strands
Expand Down

0 comments on commit 584bdf5

Please sign in to comment.