Class: ActionTrace::FetchDataChanges
- Inherits:
-
Object
- Object
- ActionTrace::FetchDataChanges
show all
- Includes:
- ActivityLogFetchable, Interactor
- Defined in:
- app/interactors/action_trace/fetch_data_changes.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
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/interactors/action_trace/fetch_data_changes.rb', line 8
def call
return unless should_fetch?('data_change')
scope = base_scope(PublicActivity::Activity)
context.total_count += scope.count
entries = scope.includes(:owner, :trackable)
.order(created_at: :desc)
.offset(context.range).limit(context.per_page)
.map do |activity|
{
id: "act_#{activity.id}",
source: source_type(activity),
occurred_at: activity.created_at,
user: activity.owner,
trackable_type: activity.trackable_type,
details: activity.parameters || {},
paper_trail_version: PaperTrail::Version.find_by(id: activity.version_id),
trackable: activity.trackable
}
end
context.raw_collection += entries
end
|