Class: Workarea::Admin::ReportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/reports_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#average_order_valueObject



6
7
8
9
10
11
# File 'app/controllers/workarea/admin/reports_controller.rb', line 6

def average_order_value
  @report = Reports::AverageOrderValueViewModel.wrap(
    Workarea::Reports::AverageOrderValue.new(params),
    view_model_options
  )
end

#customersObject



24
25
26
27
28
29
# File 'app/controllers/workarea/admin/reports_controller.rb', line 24

def customers
  @report = Reports::CustomersViewModel.wrap(
    Workarea::Reports::Customers.new(params),
    view_model_options
  )
end

#downloadObject



109
110
111
112
# File 'app/controllers/workarea/admin/reports_controller.rb', line 109

def download
  export = Workarea::Reports::Export.find(params[:id])
  send_file export.file.file, filename: export.file_name
end

#exportObject



97
98
99
100
101
102
103
104
105
106
107
# File 'app/controllers/workarea/admin/reports_controller.rb', line 97

def export
  export = Workarea::Reports::Export.new(params[:export])

  if export.save
    flash[:success] = t('workarea.admin.reports.flash_messages.success')
    redirect_back fallback_location: root_path
  else
    flash[:error] = export.errors.full_messages.to_sentence
    export.report_type.present? ? send(export.report_type) : redirect_to(root_path)
  end
end

#first_time_vs_returning_salesObject



13
14
15
16
17
18
# File 'app/controllers/workarea/admin/reports_controller.rb', line 13

def first_time_vs_returning_sales
  @report = Reports::FirstTimeVsReturningSalesViewModel.wrap(
    Workarea::Reports::FirstTimeVsReturningSales.new(params),
    view_model_options
  )
end

#insightsObject



20
21
22
# File 'app/controllers/workarea/admin/reports_controller.rb', line 20

def insights
  @insights = Reports::InsightsViewModel.wrap(nil, view_model_options)
end

#low_inventoryObject



90
91
92
93
94
95
# File 'app/controllers/workarea/admin/reports_controller.rb', line 90

def low_inventory
  @report = Reports::LowInventoryViewModel.wrap(
    Workarea::Reports::LowInventory.new(params),
    view_model_options
  )
end

#referenceObject



31
32
# File 'app/controllers/workarea/admin/reports_controller.rb', line 31

def reference
end

#sales_by_categoryObject



34
35
36
37
38
39
# File 'app/controllers/workarea/admin/reports_controller.rb', line 34

def sales_by_category
  @report = Reports::SalesByCategoryViewModel.wrap(
    Workarea::Reports::SalesByCategory.new(params),
    view_model_options
  )
end

#sales_by_countryObject



41
42
43
44
45
46
# File 'app/controllers/workarea/admin/reports_controller.rb', line 41

def sales_by_country
  @report = Reports::SalesByCountryViewModel.wrap(
    Workarea::Reports::SalesByCountry.new(params),
    view_model_options
  )
end

#sales_by_discountObject



48
49
50
51
52
53
# File 'app/controllers/workarea/admin/reports_controller.rb', line 48

def sales_by_discount
  @report = Reports::SalesByDiscountViewModel.wrap(
    Workarea::Reports::SalesByDiscount.new(params),
    view_model_options
  )
end

#sales_by_productObject



55
56
57
58
59
60
# File 'app/controllers/workarea/admin/reports_controller.rb', line 55

def sales_by_product
  @report = Reports::SalesByProductViewModel.wrap(
    Workarea::Reports::SalesByProduct.new(params),
    view_model_options
  )
end

#sales_by_skuObject



69
70
71
72
73
74
# File 'app/controllers/workarea/admin/reports_controller.rb', line 69

def sales_by_sku
  @report = Reports::SalesBySkuViewModel.wrap(
    Workarea::Reports::SalesBySku.new(params),
    view_model_options
  )
end

#sales_by_traffic_referrerObject



62
63
64
65
66
67
# File 'app/controllers/workarea/admin/reports_controller.rb', line 62

def sales_by_traffic_referrer
  @report = Reports::SalesByTrafficReferrerViewModel.wrap(
    Workarea::Reports::SalesByTrafficReferrer.new(params),
    view_model_options
  )
end

#sales_over_timeObject



76
77
78
79
80
81
# File 'app/controllers/workarea/admin/reports_controller.rb', line 76

def sales_over_time
  @report = Reports::SalesOverTimeViewModel.wrap(
    Workarea::Reports::SalesOverTime.new(params),
    view_model_options
  )
end

#searchesObject



83
84
85
86
87
88
# File 'app/controllers/workarea/admin/reports_controller.rb', line 83

def searches
  @report = Reports::SearchesViewModel.wrap(
    Workarea::Reports::Searches.new(params),
    view_model_options
  )
end