Class: Growth::Operations::RetentionReport::Generate

Inherits:
Object
  • Object
show all
Includes:
Dry::Transaction::Operation
Defined in:
lib/growth/operations/retention_report/generate.rb

Instance Method Summary collapse

Instance Method Details

#call(input) ⇒ Object



7
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 'lib/growth/operations/retention_report/generate.rb', line 7

def call(input)
  report = []
  input[:grouped_resources_count].each do |count, source_resources_ids|
    report.push(
        {
            total_source_resources_percentage: calculate_percentage(source_resources_ids.count, input[:resources_distinct_count]),
            total_source_resources: source_resources_ids.count,
            total_target_resources: count,
            total_source_resources_ids: source_resources_ids.sort
        }
    )
  end

  Success(
      {
          report: {
              source_resource: input[:source_resource],
              target_resource: input[:target_resource],
              total_associated_resources: input[:resources_distinct_count],
              total_target_resources: input[:target_resource].count,
              resources_stats: report
          }
      }
  )
end