Class: Spree::TrendingSearchReport
- Defined in:
- app/reports/spree/trending_search_report.rb
Defined Under Namespace
Classes: FrequencyDistributionPieChart, Result
Constant Summary collapse
- DEFAULT_SORTABLE_ATTRIBUTE =
:occurrences
- HEADERS =
{ searched_term: :string, occurrences: :integer }
- SEARCH_ATTRIBUTES =
{ start_date: :start_date, end_date: :end_date, keywords_cont: :keyword }
- SORTABLE_ATTRIBUTES =
[:occurrences]
Constants inherited from Report
Instance Attribute Summary
Attributes inherited from Report
#current_page, #paginate, #records_per_page, #reporting_period, #search, #sortable_attribute, #sortable_type, #total_records
Instance Method Summary collapse
- #paginated? ⇒ Boolean
- #paginated_report_query ⇒ Object
- #record_count_query ⇒ Object
- #report_query ⇒ Object
Methods inherited from Report
#active_record_sort, deeplink, #deeplink_properties, #generate, #get_results, #header_sorted?, #initialize, #name, #pagination_required?, #set_sortable_attributes, #time_scale_columns, #time_scale_columns_to_s, #time_scale_selects, #total_pages
Constructor Details
This class inherits a constructor from Spree::Report
Instance Method Details
#paginated? ⇒ Boolean
8 9 10 |
# File 'app/reports/spree/trending_search_report.rb', line 8 def paginated? true end |
#paginated_report_query ⇒ Object
22 23 24 25 26 |
# File 'app/reports/spree/trending_search_report.rb', line 22 def paginated_report_query report_query .take(records_per_page) .skip(current_page) end |
#record_count_query ⇒ Object
28 29 30 |
# File 'app/reports/spree/trending_search_report.rb', line 28 def record_count_query Spree::Report::QueryFragments.from_subquery(report_query).project(Arel.star.count) end |
#report_query ⇒ Object
32 33 34 35 36 |
# File 'app/reports/spree/trending_search_report.rb', line 32 def report_query Spree::Report::QueryFragments.from_subquery(searches) .project("count(searched_term) as occurrences", "searched_term") .group("searched_term") end |