Skip to content

Commit

Permalink
new facets
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Jan 8, 2019
1 parent 7bed786 commit c5fdb2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ def destroy

def totals
page ={size: 25, number: 1}
ttl = Client.all.map do |client|
page_prov = { size: 2000, number: 1}

ttl = Client.query("", page: page_prov).map do |client|
response = Doi.query("", client_id: client.symbol.downcase, page: page)
total = response.results.total
states = total > 0 ? facet_by_key(response.response.aggregations.states.buckets) : nil
temporal ={}
temporal[:last_thirty] = total > 0 ? facet_by_key(response.response.aggregations.last_thirty_days.buckets) : nil
temporal[:last_year] = total > 0 ? facet_by_key(response.response.aggregations.last_year.buckets) : nil
temporal[:last_two_year] = total > 0 ? facet_by_key(response.response.aggregations.last_two_year.buckets) : nil
temporal[:this_month] = total > 0 ? facet_by_date(response.response.aggregations.this_month.buckets) : nil
temporal[:this_year] = total > 0 ? facet_anual(response.response.aggregations.this_year.buckets) : nil
temporal[:last_year] = total > 0 ? facet_anual(response.response.aggregations.last_year.buckets) : nil
id = client.symbol
{id: id, title: id, count: total, states: states, temporal: temporal}
end
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@ def update
end

def totals
page ={size: 25, number: 1}
logger = Logger.new(STDOUT)
page = { size: 25, number: 1}
page_prov = { size: 500, number: 1}

ttl = Provider.all.map do |provider|
ttl = Provider.query("", page: page_prov).map do |provider|
response = Doi.query("", provider_id: provider.symbol.downcase, page: page)
logger.info response.results.total
total = response.results.total
states = total > 0 ? facet_by_key(response.response.aggregations.states.buckets) : nil
temporal ={}
temporal[:last_thirty] = total > 0 ? facet_by_key(response.response.aggregations.last_thirty_days.buckets) : nil
temporal[:last_year] = total > 0 ? facet_by_key(response.response.aggregations.last_year.buckets) : nil
temporal[:last_two_year] = total > 0 ? facet_by_key(response.response.aggregations.last_two_year.buckets) : nil
temporal[:this_month] = total > 0 ? facet_by_date(response.response.aggregations.this_month.buckets) : nil
temporal[:this_year] = total > 0 ? facet_anual(response.response.aggregations.this_year.buckets) : nil
temporal[:last_year] = total > 0 ? facet_anual(response.response.aggregations.last_year.buckets) : nil
# temporal[:providers] = total > 0 ? facet_by_key(response.response.aggregations.provider_x.buckets) : nil
id = provider.symbol
{id: id, title: id, count: total, states: states, temporal: temporal}
end
Expand Down

0 comments on commit c5fdb2b

Please sign in to comment.