Commit 8b114f1af758d95b5c8f8a02752916d17415f156

Authored by Dhruv Kapadia
1 parent bb0ce50a

Minor changes to export format

Showing 1 changed file with 6 additions and 6 deletions   Show diff stats
app/controllers/questions_controller.rb
@@ -131,7 +131,7 @@ class QuestionsController < InheritedResources::Base @@ -131,7 +131,7 @@ class QuestionsController < InheritedResources::Base
131 def export_votes 131 def export_votes
132 @question = Question.find(params[:id]) 132 @question = Question.find(params[:id])
133 133
134 - outfile = "question_#{@question.id}_votes" + Time.now.strftime("%m-%d-%Y") + ".csv" 134 + outfile = "ideamarketplace_#{@question.id}_votes" + Time.now.strftime("%m-%d-%Y") + ".csv"
135 headers = ['Vote ID', 'Session ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text', 135 headers = ['Vote ID', 'Session ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text',
136 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at'] 136 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at']
137 @votes = @question.votes 137 @votes = @question.votes
@@ -157,9 +157,9 @@ class QuestionsController < InheritedResources::Base @@ -157,9 +157,9 @@ class QuestionsController < InheritedResources::Base
157 def export_items 157 def export_items
158 @question = Question.find(params[:id], :include => [:choices, :prompts]) 158 @question = Question.find(params[:id], :include => [:choices, :prompts])
159 159
160 - outfile = "question_#{@question.id}_items_" + Time.now.strftime("%m-%d-%Y") + ".csv"  
161 - headers = ['Choice ID', 'Item ID', 'Data', 'Question ID', 'User Submitted', 'Choice Creator ID',  
162 - 'Wins', 'Losses', 'Created at', 'Updated at', 'Active', 'Score', 'Local Identifier', 160 + outfile = "ideamarketplace_#{@question.id}_ideas_" + Time.now.strftime("%m-%d-%Y") + ".csv"
  161 + headers = ['Ideamarketplace ID','Idea ID', 'Idea', 'Wins', 'Losses', 'Score','User Submitted', 'Idea Creator ID',
  162 + 'Created at', 'Last Activity', 'Active', 'Local Identifier',
163 'Prompts on Left', 'Prompts on Right', 'Prompts Count'] 163 'Prompts on Left', 'Prompts on Right', 'Prompts Count']
164 164
165 csv_data = FasterCSV.generate do |csv| 165 csv_data = FasterCSV.generate do |csv|
@@ -169,8 +169,8 @@ class QuestionsController < InheritedResources::Base @@ -169,8 +169,8 @@ class QuestionsController < InheritedResources::Base
169 @question.choices.each do |c| 169 @question.choices.each do |c|
170 user_submitted = (c.item.creator != @question.creator) ? "TRUE" : "FALSE" 170 user_submitted = (c.item.creator != @question.creator) ? "TRUE" : "FALSE"
171 171
172 - csv << [ c.id, c.item_id, "'#{c.data.strip}'", c.question_id, user_submitted , c.item.creator_id,  
173 - c.wins, c.losses, c.created_at, c.updated_at, c.active, c.score, c.local_identifier, 172 + csv << [c.question_id, c.id, "'#{c.data.strip}'", c.wins, c.losses, c.score, user_submitted , c.item.creator_id,
  173 + c.created_at, c.updated_at, c.active, c.local_identifier,
174 c.prompts_on_the_left(true).size, c.prompts_on_the_right(true).size, c.prompts_count] 174 c.prompts_on_the_left(true).size, c.prompts_on_the_right(true).size, c.prompts_count]
175 end 175 end
176 end 176 end