Class: OldSql::ShellReportFacade

Inherits:
Object
  • Object
show all
Defined in:
lib/old_sql/shell_report_facade.rb

Class Method Summary collapse

Class Method Details

.run_report(report, env, start_date, end_date, clean) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/old_sql/shell_report_facade.rb', line 5

def self.run_report(report, env, start_date, end_date, clean)
  template = File.read("#{OldSql::ReportDesign::Parser.report_design_path}/../reports.yml")
  report_config = YAML.load(Erubis::Eruby.new(template).result)[report] 
  
  Rails.env = env
  set_logger
  set_connection(env)
  
  base_parser = OldSql::ReportProcessor::Base.new
  data = base_parser.execute_query(report_config,start_date,end_date,nil)
                                   
  print_header(report, start_date, end_date, clean)
  print_data(data, report_config['fields'], clean)
  print_footer(clean)
end