Skip to content

Commit

Permalink
histogram aggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Nov 29, 2019
1 parent 777a45e commit 1a5ce1b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/queries/events_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def citations(doi)
end

def citations_histogram(doi)
pid = Event.new.normalize_doi(doi)
pid = Event.new.normalize_doi(doi.downcase.split(",").first)
query = "(subj_id:\"#{pid}\" AND (relation_type_id:#{PASSIVE_RELATION_TYPES.join(' OR relation_type_id:')})) OR (obj_id:\"#{pid}\" AND (relation_type_id:#{ACTIVE_RELATION_TYPES.join(' OR relation_type_id:')}))"
results = Event.query(query, doi: doi, aggregations: "yearly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram.buckets
facet_counts_by_year_month(results)
results = Event.query(query, doi: doi, aggregations: "yearly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram
facet_citations_by_year(results)
end


Expand All @@ -52,8 +52,9 @@ def views(doi)
end

def views_histogram(doi)
doi = doi.downcase.split(",").first
query = "(relation_type_id:unique-dataset-investigations-regular AND source_id:datacite-usage)"
results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram.buckets
results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram
facet_counts_by_year_month(results)
end

Expand All @@ -70,8 +71,9 @@ def downloads(doi)
end

def downloads_histogram(doi)
doi = doi.downcase.split(",").first
query = "(relation_type_id:unique-dataset-requests-regular AND source_id:datacite-usage)"
results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram.buckets
results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram
facet_counts_by_year_month(results)
end

Expand Down

0 comments on commit 1a5ce1b

Please sign in to comment.