Class: Report

Inherits:
Object
  • Object
show all
Defined in:
app/models/report.rb

Overview

Various reports, aggregated here for convenience

Class Method Summary (collapse)

Class Method Details

+ (Hash<Hash<String>>) issues_per_repo(run)

Returns a report of issues found per repository

Parameters:

  • run (Run)

    the Run being reported over

Returns:

  • (Hash<Hash<String>>)

    the report



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/report.rb', line 7

def self.issues_per_repo(run)
  Repository.
    joins(finding_aids: {
            finding_aid_versions: {
              concrete_issues: [:issue,:run]
            }
          }).
    where(runs: {id: run.id}).
    group('repositories.id', 'issues.id').
    order('code, substr').
    pluck('code','substr(issues.message, 0, 120)', 'COUNT(concrete_issues.id)').
    group_by {|el| el[1]}.
    map do |k, v|
      [k, v.map {|el| [el[0], el[2]]}.to_h] # Drop message from vals, then hashify
    end.to_h
end