Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit 54f53bb

Browse files
committed
Add task to import CSV of transcribed playbacks
1 parent 1007d43 commit 54f53bb

File tree

3 files changed

+130
-352
lines changed

3 files changed

+130
-352
lines changed

config/initializers/rollbar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config.access_token = '41c39af29bbc4f2e932c48f4d800f075'
66

77
# Here we'll disable in 'test':
8-
if Rails.env.test?
8+
if Rails.env.test? || Rails.env.development?
99
config.enabled = false
1010
end
1111

lib/tasks/import.rake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'csv'
2+
require 'open-uri'
3+
4+
namespace :import do
5+
desc 'Create new playbacks from CSV `rake import:transcriptions URL=http://example.com/remote.csv`'
6+
task transcriptions: :environment do
7+
CSV.parse(open(ENV['URL']), headers: :first_row, encoding: 'utf-8') do |row|
8+
playback = Playback.new(
9+
source: row[0],
10+
organisation_name: row[1],
11+
email: row[2],
12+
project_name: row[3],
13+
author_name: row[4]
14+
)
15+
16+
if playback.save
17+
{
18+
'State your problem' => [5, 6],
19+
'Explain your solution' => [7, 8],
20+
'Why are you best placed to deliver it?' => [9, 10],
21+
'What are your key assumptions and questions?' => [11, 12],
22+
'What resources do you need and what do you need them for?' => [13, 14],
23+
'What will the impact be?' => [15, 16],
24+
'This would help me communicate my work today' => [17],
25+
"This is the first thing I'm going to test" => [18]
26+
}.each do |name, rows|
27+
playback.sections.create(
28+
name: name,
29+
description: row[rows[0]],
30+
confidence: row[rows[1]]
31+
)
32+
end
33+
print '.'
34+
else
35+
print '*'
36+
end
37+
end
38+
puts
39+
end
40+
end

0 commit comments

Comments
 (0)