8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/workflows/jumbotron/workflows/execute_line_update_policy_workflow.rb', line 8
def call(adapter_id:, policy_id:)
now = Time.current
resolved = Services::Adapters::ResolveLineUpdatePolicy.call(
adapter_id: adapter_id,
policy_id: policy_id
)
return map_resolution_failure(resolved) unless resolved.success?
adapter = resolved.data[:adapter]
policy = resolved.data[:policy]
selected = Services::Adapters::SelectEligibleGames.call(
adapter: adapter,
policy: policy,
now: now
)
return map_selection_failure(selected) unless selected.success?
games = selected.data[:games]
built = Services::Adapters::BuildLineAcquisitionScopes.call(adapter: adapter, games: games)
return map_selection_failure(built) unless built.success?
scopes = built.data[:scopes]
counts = blank_counts.merge(
eligible_games: games.size,
unique_scopes: scopes.size,
skipped_incomplete_scope: built.data[:skipped_incomplete_scope]
)
return success_payload(adapter, policy, counts) if scopes.empty?
run_scopes(adapter, scopes, counts)
finish(adapter, policy, counts)
end
|