Skip to content

Commit

Permalink
change aggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Jan 8, 2019
1 parent 76f847c commit 7bed786
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ 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 } },
states: { terms: { field: 'aasm_state', size: 15, min_doc_count: 1 } },
Expand All @@ -316,9 +320,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 } },
last_thirty_days: { date_range: { field: 'created', time_zone: "CET", ranges: {from: "now-30d/d", to: "now/d"} } },
last_year: { date_range: { field: 'created', time_zone: "CET", ranges: {from: "now-1y/y", to: "now/d"} } },
last_two_year: { date_range: { field: 'created', time_zone: "CET", ranges: {from: "now-2y/y", to: "now/d"} } },
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} } }
}
end

Expand Down

0 comments on commit 7bed786

Please sign in to comment.