Class: ActionTrace::MergeAndFormatResults
- Inherits:
-
Object
- Object
- ActionTrace::MergeAndFormatResults
show all
- Includes:
- ActivityLogFetchable, Interactor
- Defined in:
- app/interactors/action_trace/merge_and_format_results.rb
Instance Method Summary
collapse
#base_scope, #should_fetch?
Instance Method Details
#call ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/interactors/action_trace/merge_and_format_results.rb', line 8
def call
sorted_results = context.raw_collection
.sort_by { |item| item[:occurred_at] }
.reverse
.first(context.per_page)
context.activity_logs = sorted_results.map { |attrs| ActionTrace::ActivityLog.new(attrs) }
total = context.total_count
context.activity_logs.define_singleton_method(:total_count) { total }
end
|