Commit 142827a4c59b005152c5c9fc42a0954f8125553f

Authored by Dhruv Kapadia
1 parent cd65ef1f

Changes in format to csv files

Showing 1 changed file with 6 additions and 3 deletions   Show diff stats
app/models/question.rb
... ... @@ -350,12 +350,13 @@ class Question < ActiveRecord::Base
350 350 outfile = "ideamarketplace_#{self.id}_votes.csv"
351 351  
352 352 headers = ['Vote ID', 'Session ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text',
353   - 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at', 'Response Time (ms)']
  353 + 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at',
  354 + 'Response Time (s)', 'Session Identifier']
354 355  
355 356 when 'ideas'
356 357 outfile = "ideamarketplace_#{self.id}_ideas.csv"
357 358 headers = ['Ideamarketplace ID','Idea ID', 'Idea Text', 'Wins', 'Losses', 'Times involved in Cant Decide', 'Score',
358   - 'User Submitted', 'Idea Creator ID', 'Created at', 'Last Activity', 'Active', 'Local Identifier',
  359 + 'User Submitted', 'Session ID', 'Created at', 'Last Activity', 'Active', 'Local Identifier',
359 360 'Appearances on Left', 'Appearances on Right']
360 361 when 'skips'
361 362 outfile = "ideamarketplace_#{self.id}_skips.csv"
... ... @@ -384,7 +385,8 @@ class Question < ActiveRecord::Base
384 385 right_id = v.prompt.nil? ? "" : v.prompt.right_choice_id
385 386  
386 387 csv << [ v.id, v.voter_id, v.question_id, v.choice_id, "\'#{v.choice.data.strip}'", v.loser_choice_id, loser_data,
387   - v.prompt_id, left_id, right_id, v.created_at, v.updated_at, v.time_viewed]
  388 + v.prompt_id, left_id, right_id, v.created_at, v.updated_at,
  389 + v.time_viewed.to_f / 1000.0 , v.voter.identifier]
388 390 end
389 391  
390 392 when 'ideas'
... ... @@ -421,6 +423,7 @@ class Question &lt; ActiveRecord::Base
421 423 end
422 424  
423 425 $redis.lpush(options[:redis_key], filename)
  426 + $redis.expire(options[:redis_key], 24*60*60 * 3) #Expire in three days
424 427 #TODO implement response_type == 'email' for use by customers of the API (not local)
425 428 end
426 429  
... ...