onebody-updateagent 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -39,11 +39,12 @@ export your people and family data to a single comma separated values (CSV) file
39
39
  Duplicate family data should be present for each member of the same family.
40
40
 
41
41
  The first row of the file is the attribute headings, and must match the attributes available:
42
+
42
43
  * [Person Attributes](http://github.com/seven1m/onebody/tree/master/app/models/person.rb)
43
44
  * [Family Attributes](http://github.com/seven1m/onebody/tree/master/app/models/family.rb)
44
45
  (prefix each attribute with "family_")
45
46
 
46
- Not all attributes are required.
47
+ Not all attributes are required.
47
48
 
48
49
  Optionally, if you have shell access to your hosted instance of OneBody, you can run
49
50
  `rake onebody:export:people:csv` to export the current OneBody data (if you have any records in
@@ -54,6 +55,8 @@ management database. Do *not* include "id" and "family_id" columns.
54
55
  * legacy\_id
55
56
  * legacy\_family\_id
56
57
 
58
+ There is an example csv file in this directory for reference.
59
+
57
60
  Converters
58
61
  ----------
59
62
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
data/bin/update_onebody CHANGED
@@ -31,9 +31,6 @@ opt_parser = OptionParser.new do |opts|
31
31
  ONEBODY_USE_CONVERTER = c['name']
32
32
  end
33
33
  end
34
- opts.on("-g", "--groups", "Sync groups.csv rather than people.csv") do |g|
35
- options[:sync_groups] = true
36
- end
37
34
  # doesn't work yet
38
35
  #opts.on("-d", "--delete", "Delete people and families not found in source file") do |d|
39
36
  # options[:delete] = true
@@ -58,58 +55,39 @@ unless options[:config_file]
58
55
  exit
59
56
  end
60
57
 
61
- if ARGV[0] # path/to/people.csv or path/to/groups.csv
58
+ if ARGV[0] # path/to/people.csv
62
59
  $: << 'lib'
63
60
  require 'onebody-updateagent'
64
61
  puts "Update Agent running at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}"
65
- if options[:sync_groups]
66
- agent = ExternalGroupUpdater.new(ARGV[0])
62
+ agent = PeopleUpdater.new(ARGV[0], config)
63
+ if options[:test]
64
+ require 'pp'
65
+ pp agent.data[0...options[:test]]
66
+ else
67
67
  puts "comparing records..."
68
- agent.compare
68
+ agent.compare(options[:force])
69
69
  if agent.has_work?
70
70
  if options[:confirm]
71
- case ask("#{agent.create.length + agent.update.length} record(s) to push. Continue? (Yes, No) ") { |q| q.in = %w(yes no y n) }
71
+ case ask("#{agent.create_count} record(s) to create and #{agent.update_count} record(s) to update. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
72
+ when 'review', 'r'
73
+ agent.present
74
+ unless agent.confirm
75
+ puts "Canceled by user\n"
76
+ exit
77
+ end
72
78
  when 'no', 'n'
73
79
  puts "Canceled by user\n"
74
80
  exit
75
81
  end
76
82
  end
83
+ agent.start_sync
77
84
  agent.push
85
+ agent.send_notification
86
+ agent.finish_sync
78
87
  puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
79
88
  else
80
89
  puts "Nothing to push\n\n"
81
90
  end
82
- else # sync people
83
- agent = PeopleUpdater.new(ARGV[0], config)
84
- if options[:test]
85
- require 'pp'
86
- pp agent.data[0...options[:test]]
87
- else
88
- puts "comparing records..."
89
- agent.compare(options[:force])
90
- if agent.has_work?
91
- if options[:confirm]
92
- case ask("#{agent.create_count} record(s) to create and #{agent.update_count} record(s) to update. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
93
- when 'review', 'r'
94
- agent.present
95
- unless agent.confirm
96
- puts "Canceled by user\n"
97
- exit
98
- end
99
- when 'no', 'n'
100
- puts "Canceled by user\n"
101
- exit
102
- end
103
- end
104
- agent.start_sync
105
- agent.push
106
- agent.send_notification
107
- agent.finish_sync
108
- puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
109
- else
110
- puts "Nothing to push\n\n"
111
- end
112
- end
113
91
  end
114
92
  else
115
93
  puts opt_parser.help
data/example.csv ADDED
@@ -0,0 +1,8 @@
1
+ birthday,child,deacon,elder,email,family_address1,family_address2,family_city,family_home_phone,family_last_name,family_name,family_state,family_zip,fax,first_name,full_access,gender,last_name,legacy_family_id,legacy_id,member,mobile_phone,sequence,staff,suffix,visible_on_printed_directory,visible_to_everyone
2
+ "Sep 17, 1973",,FALSE,FALSE,,610 W 71st St S,,Tulsa,918-555-1212,Smith,John & Jane Smith,OK,74137,,John,TRUE,Male,Smith,101,1001,TRUE,,1,FALSE,,TRUE,TRUE
3
+ "Feb 20, 1973",,FALSE,FALSE,,610 W 71st St S,,Tulsa,918-555-1212,Smith,John & Jane Smith,OK,74137,,Jane,TRUE,Female,Smith,101,1002,TRUE,918-555-4321,2,FALSE,,TRUE,TRUE
4
+ "May 18, 2005",,FALSE,FALSE,,610 W 71st St S,,Tulsa,918-555-1212,Smith,John & Jane Smith,OK,74137,,Jill,TRUE,Female,Smith,101,1003,TRUE,,3,FALSE,,TRUE,TRUE
5
+ "Nov 20, 1975",,FALSE,FALSE,eric@uploadLLC.com,5171 S 62nd Pl,,Broken Arrow,918-555-2121,Jones,Bill & Betty Jones,OK,74011,,Bob,TRUE,Male,Jones,102,1004,FALSE,918-555-1234,1,FALSE,,TRUE,TRUE
6
+ "Feb 18, 1977",,FALSE,FALSE,,5171 S 62nd Pl,,Broken Arrow,918-555-2121,Jones,Bill & Betty Jones,OK,74011,,Betty,TRUE,Female,Jones,102,1005,FALSE,,2,FALSE,,TRUE,TRUE
7
+ "Jul 8, 2003",,FALSE,FALSE,,5171 S 62nd Pl,,Broken Arrow,918-555-2121,Jones,Bill & Betty Jones,OK,74011,,Wesley,TRUE,Female,Jones,102,1006,FALSE,,3,FALSE,,TRUE,TRUE
8
+ "Jul 10, 2008",,FALSE,FALSE,,5171 S 62nd Pl,,Broken Arrow,918-555-2121,Jones,Bill & Betty Jones,OK,74011,,Mackenzie,TRUE,Female,Jones,102,1007,FALSE,,4,FALSE,,TRUE,TRUE
@@ -14,7 +14,6 @@ require 'updateagent/hash_extensions'
14
14
  require 'updateagent/updateagent'
15
15
  require 'updateagent/updaters/people_updater'
16
16
  require 'updateagent/updaters/family_updater'
17
- require 'updateagent/updaters/external_group_updater'
18
17
 
19
18
  if defined?(ONEBODY_USE_CONVERTER)
20
19
  require "updateagent/converters/#{ONEBODY_USE_CONVERTER.downcase}_converter"
@@ -15,17 +15,19 @@ class PeopleUpdater < UpdateAgent
15
15
  family_data = {}
16
16
  @data.each_with_index do |row, index|
17
17
  person, family = split_change_hash(row)
18
+ # massaging
19
+ if person.has_key?('email')
20
+ person['email_changed'] = false
21
+ end
22
+ if person.has_key?('relationships')
23
+ person['relationships_hash'] = Digest::SHA1.hexdigest(person['relationships'].split(',').sort.join(','))
24
+ end
25
+ # link to cached family or cache new family
18
26
  if existing_family = family_data[family['legacy_id']]
19
27
  person['family'] = existing_family
20
- if person.has_key?('email')
21
- person['email_changed'] = false
22
- end
23
28
  person_data << person
24
29
  else
25
30
  person['family'] = family
26
- if person.has_key?('email')
27
- person['email_changed'] = false
28
- end
29
31
  person_data << person
30
32
  family['barcode_id_changed'] = false if family.has_key?('barcode_id')
31
33
  family_data[family['legacy_id']] = family
@@ -34,6 +36,10 @@ class PeopleUpdater < UpdateAgent
34
36
  end
35
37
  puts
36
38
  @attributes << 'email_changed' if @attributes.include?('email')
39
+ if @attributes.include?('relationships')
40
+ @attributes << 'relationships_hash'
41
+ @attributes.delete('relationships')
42
+ end
37
43
  @data = person_data
38
44
  @attributes.reject! { |a| a =~ /^family_/ and a != 'family_id' }
39
45
  @family_agent = FamilyUpdater.new(family_data.values, @options)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebody-updateagent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-21 00:00:00 -06:00
12
+ date: 2010-01-18 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,7 @@ extra_rdoc_files: []
53
53
  files:
54
54
  - VERSION
55
55
  - example.yml
56
+ - example.csv
56
57
  - README.markdown
57
58
  - bin/update_onebody
58
59
  - lib/onebody-updateagent.rb
@@ -63,7 +64,6 @@ files:
63
64
  - lib/updateagent/converters/acs_converter.rb
64
65
  - lib/updateagent/updaters/family_updater.rb
65
66
  - lib/updateagent/updaters/people_updater.rb
66
- - lib/updateagent/updaters/external_group_updater.rb
67
67
  has_rdoc: true
68
68
  homepage: http://github.com/seven1m/onebody-updateagent
69
69
  licenses: []
@@ -1,30 +0,0 @@
1
- class ExternalGroupUpdater < UpdateAgent
2
- self.resource = ExternalGroup
3
-
4
- def check_for_invalid_columns; end
5
-
6
- def compare
7
- groups = resource.find(:all)
8
- @data.each do |record|
9
- if !(group = groups.detect { |g| g.external_id == record['id'] })
10
- @create << record
11
- elsif group.name != record['name'] or group.category.to_s != record['category'].to_s
12
- @update << record
13
- end
14
- end
15
- end
16
-
17
- def push
18
- puts 'Updating remote end...'
19
- @create.each do |record|
20
- group = resource.new(:external_id => record['id'], :name => record['name'], :category => record['category'])
21
- group.save
22
- end
23
- @update.each do |record|
24
- group = resource.find(record['id'], :params => {:external_id => true})
25
- group.name = record['name']
26
- group.category = record['category']
27
- group.save
28
- end
29
- end
30
- end