canvas_sync 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23899e5c41cb63d0267eb031be38b7810e84f58e
|
4
|
+
data.tar.gz: 7e6c5093980d7e07d271a85a330c2fcae8d52b54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32803f19bc38b505ab67abcdbcc55b3b283a00b79541942fea14142306ce6e569ba1746efc2d6a1d55c6eccd2b6cf7046a4f1f200e9cda9a4cd01f749f22b839
|
7
|
+
data.tar.gz: 83b5c340093e644dc26faf58ae297f937f207b0457c32b0991fad1c2194c773e49f0dff929aa0d9f4f39f6f2eafd028e1f6afc039bd240648e7b478ff03e141e
|
@@ -19,7 +19,7 @@ module CanvasSync
|
|
19
19
|
# This can be used if you need to filter or massage the data in any way.
|
20
20
|
def self.import(report_file_path, mapping, klass, conflict_target, exclude_duplicates=false)
|
21
21
|
csv_column_names = mapping.keys
|
22
|
-
database_column_names = mapping.values
|
22
|
+
database_column_names = mapping.values.map{ |value| value[:database_column_name] }
|
23
23
|
rows = []
|
24
24
|
row_ids = {}
|
25
25
|
|
@@ -32,7 +32,13 @@ module CanvasSync
|
|
32
32
|
row_ids[row[conflict_target]] = true
|
33
33
|
end
|
34
34
|
|
35
|
-
rows << csv_column_names.map
|
35
|
+
rows << csv_column_names.map do |column|
|
36
|
+
if mapping[column][:type] == :datetime
|
37
|
+
DateTime.parse(row[column]).utc if row[column].present?
|
38
|
+
else
|
39
|
+
row[column]
|
40
|
+
end
|
41
|
+
end
|
36
42
|
|
37
43
|
if rows.length >= batch_size
|
38
44
|
perform_import(klass, database_column_names, rows, conflict_target)
|
@@ -8,55 +8,166 @@ module CanvasSync
|
|
8
8
|
# Used by the {CanvasSync::Importers::BulkImporter bulk importer}. The keys are
|
9
9
|
# CSV columns and the values are the database columns.
|
10
10
|
USERS_CSV_MAPPING = {
|
11
|
-
canvas_user_id:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
canvas_user_id: {
|
12
|
+
database_column_name: :canvas_user_id,
|
13
|
+
type: :integer
|
14
|
+
},
|
15
|
+
user_id: {
|
16
|
+
database_column_name: :sis_id,
|
17
|
+
type: :string
|
18
|
+
},
|
19
|
+
email: {
|
20
|
+
database_column_name: :email,
|
21
|
+
type: :string
|
22
|
+
},
|
23
|
+
first_name: {
|
24
|
+
database_column_name: :first_name,
|
25
|
+
type: :string
|
26
|
+
},
|
27
|
+
last_name: {
|
28
|
+
database_column_name: :last_name,
|
29
|
+
type: :string
|
30
|
+
},
|
31
|
+
status: {
|
32
|
+
database_column_name: :status,
|
33
|
+
type: :string
|
34
|
+
},
|
35
|
+
login_id: {
|
36
|
+
database_column_name: :login_id,
|
37
|
+
type: :string
|
38
|
+
}
|
18
39
|
}
|
19
40
|
|
20
41
|
COURSES_CSV_MAPPING = {
|
21
|
-
canvas_course_id:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
42
|
+
canvas_course_id: {
|
43
|
+
database_column_name: :canvas_course_id,
|
44
|
+
type: :integer
|
45
|
+
},
|
46
|
+
course_id: {
|
47
|
+
database_column_name: :sis_id,
|
48
|
+
type: :string
|
49
|
+
},
|
50
|
+
short_name: {
|
51
|
+
database_column_name: :short_name,
|
52
|
+
type: :string
|
53
|
+
},
|
54
|
+
long_name: {
|
55
|
+
database_column_name: :long_name,
|
56
|
+
type: :string
|
57
|
+
},
|
58
|
+
canvas_account_id: {
|
59
|
+
database_column_name: :canvas_account_id,
|
60
|
+
type: :integer
|
61
|
+
},
|
62
|
+
canvas_term_id: {
|
63
|
+
database_column_name: :canvas_term_id,
|
64
|
+
type: :integer
|
65
|
+
},
|
66
|
+
term_id: {
|
67
|
+
database_column_name: :term_sis_id,
|
68
|
+
type: :string
|
69
|
+
},
|
70
|
+
start_date: {
|
71
|
+
database_column_name: :start_date,
|
72
|
+
type: :datetime
|
73
|
+
},
|
74
|
+
end_date: {
|
75
|
+
database_column_name: :end_date,
|
76
|
+
type: :datetime
|
77
|
+
},
|
78
|
+
status: {
|
79
|
+
database_column_name: :status,
|
80
|
+
type: :integer
|
81
|
+
}
|
31
82
|
}
|
32
83
|
|
33
84
|
ENROLLMENTS_CSV_MAPPING = {
|
34
|
-
canvas_enrollment_id:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
85
|
+
canvas_enrollment_id: {
|
86
|
+
database_column_name: :canvas_enrollment_id,
|
87
|
+
type: :integer
|
88
|
+
},
|
89
|
+
canvas_course_id: {
|
90
|
+
database_column_name: :canvas_course_id,
|
91
|
+
type: :integer
|
92
|
+
},
|
93
|
+
course_id: {
|
94
|
+
database_column_name: :course_sis_id,
|
95
|
+
type: :string
|
96
|
+
},
|
97
|
+
canvas_user_id: {
|
98
|
+
database_column_name: :canvas_user_id,
|
99
|
+
type: :integer
|
100
|
+
},
|
101
|
+
user_id: {
|
102
|
+
database_column_name: :user_sis_id,
|
103
|
+
type: :string
|
104
|
+
},
|
105
|
+
role: {
|
106
|
+
database_column_name: :role,
|
107
|
+
type: :string
|
108
|
+
},
|
109
|
+
role_id: {
|
110
|
+
database_column_name: :role_id,
|
111
|
+
type: :integer
|
112
|
+
},
|
113
|
+
canvas_section_id: {
|
114
|
+
database_column_name: :canvas_section_id,
|
115
|
+
type: :integer
|
116
|
+
},
|
117
|
+
section_id: {
|
118
|
+
database_column_name: :section_sis_id,
|
119
|
+
type: :string
|
120
|
+
},
|
121
|
+
status: {
|
122
|
+
database_column_name: :status,
|
123
|
+
type: :string
|
124
|
+
},
|
125
|
+
base_role_type: {
|
126
|
+
database_column_name: :base_role_type,
|
127
|
+
type: :string
|
128
|
+
}
|
45
129
|
}
|
46
130
|
|
47
131
|
SECTIONS_CSV_MAPPING = {
|
48
|
-
canvas_section_id:
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
132
|
+
canvas_section_id: {
|
133
|
+
database_column_name: :canvas_section_id,
|
134
|
+
type: :integer
|
135
|
+
},
|
136
|
+
section_id: {
|
137
|
+
database_column_name: :sis_id,
|
138
|
+
type: :string
|
139
|
+
},
|
140
|
+
canvas_course_id: {
|
141
|
+
database_column_name: :canvas_course_id,
|
142
|
+
type: :integer
|
143
|
+
},
|
144
|
+
name: {
|
145
|
+
database_column_name: :name,
|
146
|
+
type: :string
|
147
|
+
},
|
148
|
+
status: {
|
149
|
+
database_column_name: :status,
|
150
|
+
type: :string
|
151
|
+
},
|
152
|
+
start_date: {
|
153
|
+
database_column_name: :start_date,
|
154
|
+
type: :datetime
|
155
|
+
},
|
156
|
+
end_date: {
|
157
|
+
database_column_name: :end_date,
|
158
|
+
type: :datetime
|
159
|
+
}
|
55
160
|
}
|
56
161
|
|
57
162
|
XLIST_CSV_MAPPING = {
|
58
|
-
canvas_section_id:
|
59
|
-
|
163
|
+
canvas_section_id: {
|
164
|
+
database_column_name: :canvas_section_id,
|
165
|
+
type: :integer
|
166
|
+
},
|
167
|
+
canvas_nonxlist_course_id: {
|
168
|
+
database_column_name: :canvas_nonxlist_course_id,
|
169
|
+
type: :integer
|
170
|
+
}
|
60
171
|
}
|
61
172
|
|
62
173
|
# Processes a provisioning report using the bulk importer.
|
data/lib/canvas_sync/version.rb
CHANGED
@@ -14,6 +14,9 @@ RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
|
|
14
14
|
expect {
|
15
15
|
subject.process('spec/support/fixtures/reports/courses.csv', { models: ['courses'] })
|
16
16
|
}.to change { Course.count }.by(2)
|
17
|
+
course = Course.first
|
18
|
+
expect(course.start_date).to eq DateTime.parse("2017-03-27 21:53:18")
|
19
|
+
expect(course.end_date).to eq DateTime.parse("2017-04-27 12:21:18")
|
17
20
|
end
|
18
21
|
|
19
22
|
it 'processes enrollments' do
|
@@ -26,6 +29,9 @@ RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
|
|
26
29
|
expect {
|
27
30
|
subject.process('spec/support/fixtures/reports/sections.csv', { models: ['sections'] })
|
28
31
|
}.to change { Section.count }.by(2)
|
32
|
+
section = Section.first
|
33
|
+
expect(section.start_date).to eq DateTime.parse("2017-03-27 21:53:18")
|
34
|
+
expect(section.end_date).to eq DateTime.parse("2017-03-27 21:53:18")
|
29
35
|
end
|
30
36
|
|
31
37
|
it 'processes xlist' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Collings
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|