seven1m-onebody-updateagent 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/update_onebody +23 -15
- data/lib/updateagent/converters/acs_converter.rb +12 -2
- metadata +2 -3
data/bin/update_onebody
CHANGED
@@ -15,6 +15,9 @@ opt_parser = OptionParser.new do |opts|
|
|
15
15
|
opts.on("-f", "--force", "Force update all records") do |f|
|
16
16
|
options[:force] = true
|
17
17
|
end
|
18
|
+
opts.on("-t", "--test COUNT", "Test input and conversion without sending data to OneBody - show first COUNT records") do |test|
|
19
|
+
options[:test] = test.to_i
|
20
|
+
end
|
18
21
|
opts.on("-c", "--config-file PATH", "Path to configuration file") do |c|
|
19
22
|
options[:config_file] = c
|
20
23
|
config = YAML::load(File.read(c))
|
@@ -64,26 +67,31 @@ if ARGV[0] # path/to/people.csv or path/to/groups.csv
|
|
64
67
|
end
|
65
68
|
else # sync people
|
66
69
|
agent = PeopleUpdater.new(ARGV[0])
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
if options[:test]
|
71
|
+
require 'pp'
|
72
|
+
pp agent.data[0...options[:test]]
|
73
|
+
else
|
74
|
+
puts "comparing records..."
|
75
|
+
agent.compare(options[:force])
|
76
|
+
if agent.has_work?
|
77
|
+
if options[:confirm]
|
78
|
+
case ask("#{agent.create.length + agent.update.length} record(s) to push. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
|
79
|
+
when 'review', 'r'
|
80
|
+
agent.present
|
81
|
+
unless agent.confirm
|
82
|
+
puts "Canceled by user\n"
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
when 'no', 'n'
|
75
86
|
puts "Canceled by user\n"
|
76
87
|
exit
|
77
88
|
end
|
78
|
-
when 'no', 'n'
|
79
|
-
puts "Canceled by user\n"
|
80
|
-
exit
|
81
89
|
end
|
90
|
+
agent.push
|
91
|
+
puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
|
92
|
+
else
|
93
|
+
puts "Nothing to push\n\n"
|
82
94
|
end
|
83
|
-
agent.push
|
84
|
-
puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
|
85
|
-
else
|
86
|
-
puts "Nothing to push\n\n"
|
87
95
|
end
|
88
96
|
end
|
89
97
|
else
|
@@ -3,7 +3,6 @@ class ACSConverter
|
|
3
3
|
def straight
|
4
4
|
{
|
5
5
|
"FamilyNumber" => "legacy_family_id",
|
6
|
-
"IndividualNumber" => "sequence",
|
7
6
|
"LastName" => "last_name",
|
8
7
|
"Suffix" => "suffix",
|
9
8
|
"Address1" => "family_address1",
|
@@ -20,6 +19,7 @@ class ACSConverter
|
|
20
19
|
|
21
20
|
def convert(records)
|
22
21
|
create_family_names(records)
|
22
|
+
create_family_sequences(records)
|
23
23
|
records.map do |record|
|
24
24
|
convert_record(record)
|
25
25
|
end
|
@@ -32,7 +32,7 @@ class ACSConverter
|
|
32
32
|
new_record[new_key] = value
|
33
33
|
end
|
34
34
|
end
|
35
|
-
new_record['legacy_id'] = new_record['legacy_family_id'] +
|
35
|
+
new_record['legacy_id'] = new_record['legacy_family_id'] + record['IndividualNumber']
|
36
36
|
new_record['first_name'] = get_first_name(record)
|
37
37
|
new_record['family_home_phone'] = get_phone(record, 'Home')
|
38
38
|
new_record['work_phone'] = get_phone(record, 'Business')
|
@@ -46,6 +46,7 @@ class ACSConverter
|
|
46
46
|
new_record['can_sign_in'] = CONVERTER_CONFIG['full_access'].include?(record['MemberStatus'])
|
47
47
|
new_record['email'] = record['HomeEmailAddr'].to_s.any? ? record['HomeEmailAddr'] : record['BusinessEmailAddr']
|
48
48
|
new_record['child'] = new_record['birthday'].to_s.empty? ? record['FamilyPosition'] == 'Child' : nil
|
49
|
+
new_record['sequence'] = @families_by_sequence[new_record['legacy_family_id']].index(record['IndividualNumber'].to_i) + 1
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -71,6 +72,15 @@ class ACSConverter
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
75
|
+
def create_family_sequences(records)
|
76
|
+
@families_by_sequence = {}
|
77
|
+
records.each do |record|
|
78
|
+
@families_by_sequence[record['FamilyNumber']] ||= []
|
79
|
+
@families_by_sequence[record['FamilyNumber']] << record['IndividualNumber'].to_i
|
80
|
+
end
|
81
|
+
@families_by_sequence.each { |k, v| v.sort! }
|
82
|
+
end
|
83
|
+
|
74
84
|
def get_first_name(record)
|
75
85
|
record['GoesByName'].to_s.any? ? record['GoesByName'] : record['FirstName']
|
76
86
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seven1m-onebody-updateagent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Morgan
|
@@ -65,7 +65,6 @@ files:
|
|
65
65
|
- lib/updateagent/updaters/people_updater.rb
|
66
66
|
has_rdoc: false
|
67
67
|
homepage: http://github.com/seven1m/onebody-updateagent
|
68
|
-
licenses:
|
69
68
|
post_install_message:
|
70
69
|
rdoc_options: []
|
71
70
|
|
@@ -86,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
85
|
requirements: []
|
87
86
|
|
88
87
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.2.0
|
90
89
|
signing_key:
|
91
90
|
specification_version: 2
|
92
91
|
summary: Companion to OneBody that handles sync with external data source.
|