Module: Admin::HealthHelper

Defined in:
app/helpers/admin/health_helper.rb

Instance Method Summary collapse

Instance Method Details

#delayed_job_queueObject

Returns Hash project_name => total missing records of kind.

Returns:

  • Hash project_name => total missing records of kind



12
13
14
15
16
17
18
19
# File 'app/helpers/admin/health_helper.rb', line 12

def delayed_job_queue
  h = Hash.new(0)

  ::Delayed::Job.all.each do |j|
    h[j.queue] += 1
  end
  h
end

#stale_dwc_occurrences(kind = 'CollectionObject') ⇒ Object

Returns Hash project_name => total missing records of kind.

Returns:

  • Hash project_name => total missing records of kind



5
6
7
8
# File 'app/helpers/admin/health_helper.rb', line 5

def stale_dwc_occurrences(kind = 'CollectionObject')
  table = kind.tableize
  ApplicationRecord.connection.execute("select dwc.project_id, count(dwc.project_id) t from dwc_occurrences dwc left join #{table} tbl on dwc.dwc_occurrence_object_id = tbl.id where tbl.id is null and dwc.dwc_occurrence_object_type = '#{kind}' group by dwc.project_id;").inject({}){|hsh, v| hsh[ Project.find(v['project_id']).name ] =  v['t']; hsh}
end