Skip to content

Commit

Permalink
Removes tertiary statements I added
Browse files Browse the repository at this point in the history
  • Loading branch information
torresga committed Oct 30, 2024
1 parent 2d268d8 commit 126d8c1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,25 @@ def export

def generate_csv(stories, with_comments: false, export_all: false)
CSV.generate(headers: true) do |csv|
csv << (with_comments ? (CSV_HEADERS + ["comment"]) : CSV_HEADERS)
headers = if with_comments
CSV_HEADERS + ["comment"]
else
CSV_HEADERS
end

csv << headers

stories.by_position.each do |story|
if with_comments
comments = []
story.comments.each do |comment|
comments << "#{display_name(comment.user)}: #{comment.body}"
end

csv << [story.id, story.title, story.description, story.position] + comments
else
csv << story.attributes.slice(*CSV_HEADERS)
end
csv << (with_comments ? ([story.id, story.title, story.description, story.position] + comments) : story.attributes.slice(*CSV_HEADERS))
end
end
end
Expand Down

0 comments on commit 126d8c1

Please sign in to comment.