Commit 142827a4c59b005152c5c9fc42a0954f8125553f
1 parent
cd65ef1f
Exists in
master
and in
1 other branch
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,12 +350,13 @@ class Question < ActiveRecord::Base | ||
350 | outfile = "ideamarketplace_#{self.id}_votes.csv" | 350 | outfile = "ideamarketplace_#{self.id}_votes.csv" |
351 | 351 | ||
352 | headers = ['Vote ID', 'Session ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text', | 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 | when 'ideas' | 356 | when 'ideas' |
356 | outfile = "ideamarketplace_#{self.id}_ideas.csv" | 357 | outfile = "ideamarketplace_#{self.id}_ideas.csv" |
357 | headers = ['Ideamarketplace ID','Idea ID', 'Idea Text', 'Wins', 'Losses', 'Times involved in Cant Decide', 'Score', | 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 | 'Appearances on Left', 'Appearances on Right'] | 360 | 'Appearances on Left', 'Appearances on Right'] |
360 | when 'skips' | 361 | when 'skips' |
361 | outfile = "ideamarketplace_#{self.id}_skips.csv" | 362 | outfile = "ideamarketplace_#{self.id}_skips.csv" |
@@ -384,7 +385,8 @@ class Question < ActiveRecord::Base | @@ -384,7 +385,8 @@ class Question < ActiveRecord::Base | ||
384 | right_id = v.prompt.nil? ? "" : v.prompt.right_choice_id | 385 | right_id = v.prompt.nil? ? "" : v.prompt.right_choice_id |
385 | 386 | ||
386 | csv << [ v.id, v.voter_id, v.question_id, v.choice_id, "\'#{v.choice.data.strip}'", v.loser_choice_id, loser_data, | 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 | end | 390 | end |
389 | 391 | ||
390 | when 'ideas' | 392 | when 'ideas' |
@@ -421,6 +423,7 @@ class Question < ActiveRecord::Base | @@ -421,6 +423,7 @@ class Question < ActiveRecord::Base | ||
421 | end | 423 | end |
422 | 424 | ||
423 | $redis.lpush(options[:redis_key], filename) | 425 | $redis.lpush(options[:redis_key], filename) |
426 | + $redis.expire(options[:redis_key], 24*60*60 * 3) #Expire in three days | ||
424 | #TODO implement response_type == 'email' for use by customers of the API (not local) | 427 | #TODO implement response_type == 'email' for use by customers of the API (not local) |
425 | end | 428 | end |
426 | 429 |