Sha256: 24080767c5d38812e8209f6675f4f84ff9ffef46bd1672117065117a06cf0261
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require_dependency "renalware/reporting" module Renalware module Reporting class GenerateAuditJson def self.call(view_name) conn = ActiveRecord::Base.connection result = conn.execute("select * from #{conn.quote_column_name(view_name)};") # Build a JS DataTables-compatible columnDefs hash columns = result.fields.each_with_index.inject([]) do |array, data| column_name, index = data array << { title: column_name, target: index } end [columns.to_json, result.values] end # A WIP to translate audit column names into human friendly ones. # May need to establish guidelines for instance apply text case in the view itself so # eg pct_HGB = % HGB without having to know to upcase certain bits of the name but # capitalise others etc. # def self.humanize_column_name(column) # column # .gsub("pct_", "% ") # .gsub("count_", "No.") # .gsub("avg_", "Avg ") # .gsub("max", "Max ") # .gsub("gt_eq_", "≥ ") # .gsub("lt_eq_", "≤ ") # .gsub("gt_", "> ") # .gsub("lt_", "< ") # end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
renalware-core-2.0.0.pre.beta9 | app/models/renalware/reporting/generate_audit_json.rb |