Class: CodeSunset::FeaturesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/code_sunset/features_controller.rb

Constant Summary collapse

RECENT_EVENTS_PER_PAGE =
25

Instance Method Summary collapse

Instance Method Details

#index ⇒ Object



7
8
9
# File 'app/controllers/code_sunset/features_controller.rb', line 7

def index
  @summaries = CodeSunset::FeatureQuery.new(filters).call
end

#show ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/code_sunset/features_controller.rb', line 11

def show
  @summary = CodeSunset::FeatureQuery.new(filters, scope: CodeSunset::Feature.where(id: @feature.id)).call.first
  @usage_series = CodeSunset::FeatureUsageSeries.new(feature: @feature, filters: filters).call

  scoped_events = @feature.events.apply_filters(filters).where(occurred_at: 30.days.ago..Time.current)
  @top_orgs = CodeSunset::Event.top_orgs(scoped_events, limit: 8)
  @top_users = CodeSunset::Event.top_users(scoped_events, limit: 8)
  @request_paths = CodeSunset::Event.top_request_paths(scoped_events, limit: 8)
  @job_usage = CodeSunset::Event.top_job_classes(scoped_events, limit: 8)

  recent_events_scope = @feature.events.apply_filters(filters.except(:page)).recent_first
  @recent_events_page = requested_recent_events_page
  @recent_events_per_page = RECENT_EVENTS_PER_PAGE
  @recent_events_total_count = recent_events_scope.count
  @recent_events_total_pages = [(@recent_events_total_count.to_f / @recent_events_per_page).ceil, 1].max
  @recent_events_page = [@recent_events_page, @recent_events_total_pages].min
  @recent_events = recent_events_scope.offset((@recent_events_page - 1) * @recent_events_per_page).limit(@recent_events_per_page)

  @removal_prompt_artifact = build_removal_prompt_artifact if generate_removal_prompt?
end