Class: EducodeSales::OperationsController
Instance Method Summary
collapse
#authenticate_admin, #authenticate_request, #current_user, #filter, #is_commissioner_above?, #paginate, #render_failure, #render_success, #subject_members, #subject_staffs, #subject_url
#add_businesses_score, #base_url, #collection_amount_score, #completion_rate, #current?, #disk_filename, #get_businesses_chart, #handled_data, #handled_time_data, #handled_time_data_accurate, #relative_path, #signed_amount_score, #storage_path, #url_to_avatar, #visits_score
Instance Method Details
#operations ⇒ Object
28
29
30
|
# File 'app/controllers/educode_sales/operations_controller.rb', line 28
def operations
end
|
#sale_trends ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/controllers/educode_sales/operations_controller.rb', line 19
def sale_trends
sale_trend = OperationTrend.find_by(year: params[:year])
if sale_trend.update(sale_trend_params)
render_success
else
render_failure sale_trend
end
end
|
#trends ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'app/controllers/educode_sales/operations_controller.rb', line 6
def trends
@years = (1..(Time.now.year - 2014)).reverse_each.map { |d| 2014 + d }
@year = params[:year] ? params[:year] : Time.now.year
@operation_trend = OperationTrend.find_or_create_by(year: @year)
@inc_users_count = User.where("created_on > ? AND created_on <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").count
@inc_teachers_count = User.joins(:user_extension).where(user_extensions: {identity: 'teacher'}).where("created_on > ? AND created_on <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").count
@courses_count = Course.where("created_at > ? AND created_at <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").count
@teachers_count = User.joins(user_extension: [school: :school_property]).
where("school_properties.project_985 = true OR school_properties.project_211 = true").
where(user_extensions: {identity: 'teacher'}).
where("created_on > ? AND created_on <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").count
end
|