Skip to content

Commit

Permalink
added fix for challenge csv download
Browse files Browse the repository at this point in the history
  • Loading branch information
ArjunAranetaCodes committed Sep 19, 2024
1 parent e82fd50 commit c00b32a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/models/challenge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ def type

# Compiles a CSV file of all challenges.
# ENHANCEMENT: This should be in a helper object or own model.
def self.to_csv(competition, options = {})
def self.to_csv(competition, options={})
challenge_columns = %w[id name short_desc long_desc eligibility video_url created_at updated_at]
CSV.generate(options) do |csv|
#CSV.generate(options) do |csv|
CSV.generate do |csv|
csv << (%w[region_name competition_year] + challenge_columns + %w[sponsors entries])
competition.challenges.preload(:region, :sponsors, :published_entries).each do |challenge|
csv << challenge_csv_line(challenge, competition, challenge_columns)
formatted_values = challenge_csv_line(challenge, competition, challenge_columns).map(&:to_s)
csv << formatted_values
#csv << challenge_csv_line(challenge, competition, challenge_columns)
end
end
end
Expand Down

0 comments on commit c00b32a

Please sign in to comment.