Skip to content

Commit

Permalink
store the aggregation results in a instance variable to avoid multipl…
Browse files Browse the repository at this point in the history
…e request
  • Loading branch information
kjgarza committed Aug 18, 2021
1 parent 475b5a0 commit 120dffc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/graphql/types/person_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,20 @@ def works(**args)

def view_count
args = { first: 0 }
r = response(args)
r.response.aggregations.view_count.value.to_i
@r = response(args) if @r.nil?
@r.response.aggregations.view_count.value.to_i
end

def download_count
args = { first: 0 }
r = response(args)
r.response.aggregations.download_count.value.to_i
@r = response(args) if @r.nil?
@r.response.aggregations.download_count.value.to_i
end

def citation_count
args = { first: 0 }
r = response(args)
r.response.aggregations.citation_count.value.to_i
@r = response(args) if @r.nil?
@r.response.aggregations.citation_count.value.to_i
end

def response(**args)
Expand Down

0 comments on commit 120dffc

Please sign in to comment.