module Export::Races::Race

Public Class Methods

export() click to toggle source
# File app/models/export/races.rb, line 5
def Race.export
  Race.export_head
  Race.export_data
end
export_columns() click to toggle source
# File app/models/export/races.rb, line 34
def Race.export_columns
  [
    "id", "event_id", "category_id", "city", "state", "distance",
    "field_size", "laps", "time", "finishers"
  ]
end
export_data() click to toggle source
# File app/models/export/races.rb, line 16
def Race.export_data
  Base.export(export_data_sql, "races.csv")
end
export_data_sql() click to toggle source
# File app/models/export/races.rb, line 26
def Race.export_data_sql
  "SELECT #{Race.export_columns.join(",")}
   INTO OUTFILE '%s'
   FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
   LINES TERMINATED BY '\\n'
   FROM races"
end
export_head() click to toggle source
# File app/models/export/races.rb, line 12
def Race.export_head
  Base.export(export_head_sql, "races.txt")
end
export_head_sql() click to toggle source
# File app/models/export/races.rb, line 20
def Race.export_head_sql
  "SELECT '#{Race.export_columns.join("','")}'
   INTO OUTFILE '%s'
   FIELDS TERMINATED BY '\\n'"
end