Skip to content

Commit

Permalink
aggregations moving
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Feb 12, 2019
1 parent ec3513c commit 2f3ace4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
5 changes: 0 additions & 5 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ def index
link_checks_citation_doi = total > 0 ? response.response.aggregations.link_checks_citation_doi.value : nil
links_checked = total > 0 ? response.response.aggregations.links_checked.value : nil
subjects = total > 0 ? facet_by_key(response.response.aggregations.subjects.buckets) : nil
clients_totals = total > 0 ? facet_by_clients_totals(response.response.aggregations.clients_totals.buckets) : nil
providers_totals = total > 0 ? facet_by_clients_totals(response.response.aggregations.providers_totals.buckets) : nil


respond_to do |format|
format.json do
Expand All @@ -123,8 +120,6 @@ def index
providers: providers,
clients: clients,
prefixes: prefixes,
totals_client: clients_totals,
totals_provider: providers_totals,
"schemaVersions" => schema_versions,
sources: sources,
"linkChecksStatus" => link_checks_status,
Expand Down
11 changes: 3 additions & 8 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ def as_indexed_json(options={})
end

def self.query_aggregations
beginning_of_year = DateTime.current.beginning_of_year.strftime('%Y-%m-%d')
beginning_of_last_year = DateTime.current.beginning_of_year.last_year.strftime('%Y-%m-%d')
beginning_of_month = DateTime.current.beginning_of_month.strftime('%Y-%m-%d')

{
resource_types: { terms: { field: 'types.resourceTypeGeneral', size: 15, min_doc_count: 1 } },
Expand All @@ -322,11 +319,9 @@ def self.query_aggregations
link_checks_citation_doi: { value_count: { field: "landing_page.citationDoi" } },
links_checked: { value_count: { field: "landing_page.checked" } },
sources: { terms: { field: 'source', size: 15, min_doc_count: 1 } },
providers_totals: { terms: { field: 'provider_id', size: 500, min_doc_count: 0 }, aggs: sub_aggregations},
clients_totals: { terms: { field: 'client_id', size: 2000, min_doc_count: 0 }, aggs: sub_aggregations },
this_month:{ date_range:{ field: 'created', time_zone: "CET", ranges: {from: beginning_of_month, to: "now/d"} } },
this_year: { date_range: { field: 'created', time_zone: "CET", ranges: {from: beginning_of_year, to: "now/d"} } },
last_year: { date_range: { field: 'created', time_zone: "CET", ranges: {from: beginning_of_last_year, to: beginning_of_year} } },
providers_totals: { terms: { field: 'provider_id', size: 500, min_doc_count: 1 }, aggs: sub_aggregations},
clients_totals: { terms: { field: 'client_id', size: 2000, min_doc_count: 1 }, aggs: sub_aggregations },
prefixes_totals: { terms: { field: 'prefix', size: 2000, min_doc_count: 1 }, aggs: sub_aggregations },
subjects: { terms: { field: 'subjects.subject', size: 15, min_doc_count: 1 } }
}
end
Expand Down

0 comments on commit 2f3ace4

Please sign in to comment.