Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Renamed properly some methods and variables related to new user synch…

…ronization.
  • Loading branch information...
commit 30f0e84efa0289ca77ba8883e1752455e67306ab 1 parent 3c01977
Álvaro Martín Fraguas amartinfraguas authored
18 lib/api_operations/contacts.rb
@@ -25,27 +25,27 @@ def self.synchronize_account(account, new_user_maps)
25 25
26 26 COMPLEX_CONVERSIONS = [:im,:website,:address]
27 27
28   - def self.synchronize_account_process(account, user_map)
  28 + def self.synchronize_account_process(account, new_user_map)
29 29 # if there is a new user map
30   - if user_map
31   - ApiOperations::Common.log(:debug,nil,"Started contact synchronization of the new user map with id = " + user_map.id.to_s + " and account with id = " + account.id.to_s)
  30 + if new_user_map
  31 + ApiOperations::Common.log(:debug,nil,"Started contact synchronization of the new user map with id = " + new_user_map.id.to_s + " and account with id = " + account.id.to_s)
32 32
33 33 begin
34 34 # get the feed of all contacts for this new user map of this Ringio account from Ringio
35   - user_rg_feed = self.fetch_individual_user_rg_feed user_map
  35 + user_rg_feed = self.fetch_individual_new_user_rg_feed new_user_map
36 36 # as it is the first synchronization for this user map, we are not interested in deleted contacts
37 37 rg_deleted_contact_ids = []
38 38 rescue Exception => e
39   - ApiOperations::Common.log(:error,e,"\nProblem fetching the contacts of the new user map with id = " + user_map.id.to_s + " and account with id = " + account.id.to_s)
  39 + ApiOperations::Common.log(:error,e,"\nProblem fetching the contacts of the new user map with id = " + new_user_map.id.to_s + " and account with id = " + account.id.to_s)
40 40 end
41 41
42 42 begin
43   - self.synchronize_user(true,user_map,user_rg_feed,rg_deleted_contact_ids)
  43 + self.synchronize_user(true,new_user_map,user_rg_feed,rg_deleted_contact_ids)
44 44 rescue Exception => e
45   - ApiOperations::Common.log(:error,e,"\nProblem synchronizing the contacts of the new user map with id = " + um.id.to_s)
  45 + ApiOperations::Common.log(:error,e,"\nProblem synchronizing the contacts of the new user map with id = " + new_user_map.id.to_s)
46 46 end
47 47
48   - ApiOperations::Common.log(:debug,nil,"Finished contact synchronization of the new user map with id = " + user_map.id.to_s + " and account with id = " + account.id.to_s)
  48 + ApiOperations::Common.log(:debug,nil,"Finished contact synchronization of the new user map with id = " + new_user_map.id.to_s + " and account with id = " + account.id.to_s)
49 49 else
50 50 begin
51 51 # get the feed of changed contacts per user of this Ringio account from Ringio
@@ -127,7 +127,7 @@ def self.fetch_user_rg_feeds(account_rg_feed, account)
127 127 end
128 128
129 129 # behaves like self.fetch_user_rg_feeds but just for the element of the array for this user map
130   - def self.fetch_individual_user_rg_feed(user_map)
  130 + def self.fetch_individual_new_user_rg_feed(user_map)
131 131 updated_rg_contacts = user_map.all_rg_contacts_feed.updated.inject([]) do |u_rg_contacts,rg_contact_id|
132 132 rg_contact = RingioAPI::Contact.find rg_contact_id
133 133
20 lib/api_operations/notes.rb
@@ -41,27 +41,27 @@ def self.remove_subject_name(hr_note)
41 41
42 42 private
43 43
44   - def self.synchronize_account_process(account, user_map)
  44 + def self.synchronize_account_process(account, new_user_map)
45 45 # if there is a new user map
46   - if user_map
47   - ApiOperations::Common.log(:debug,nil,"Started note synchronization for the new user map with id = " + user_map.id.to_s + " of the account with id = " + account.id.to_s)
  46 + if new_user_map
  47 + ApiOperations::Common.log(:debug,nil,"Started note synchronization for the new user map with id = " + new_user_map.id.to_s + " of the account with id = " + account.id.to_s)
48 48
49 49 begin
50 50 # get the feed of changed notes per contact of this new user map
51   - user_feed = self.fetch_individual_user_feed user_map
  51 + user_feed = self.fetch_individual_new_user_feed new_user_map
52 52 # as it is the first synchronization for this user map, we are not interested in deleted notes
53 53 rg_deleted_notes_ids = []
54 54 rescue Exception => e
55   - ApiOperations::Common.log(:error,e,"\nProblem fetching the changed notes for the new user map with id = " + user_map.id.to_s + " of the account with id = " + account.id.to_s)
  55 + ApiOperations::Common.log(:error,e,"\nProblem fetching the changed notes for the new user map with id = " + new_user_map.id.to_s + " of the account with id = " + account.id.to_s)
56 56 end
57 57
58 58 begin
59   - self.synchronize_user user_feed
  59 + self.synchronize_new_user user_feed
60 60 rescue Exception => e
61   - ApiOperations::Common.log(:error,e,"\nProblem synchronizing the notes of the new user map with id = " + user_map.id.to_s)
  61 + ApiOperations::Common.log(:error,e,"\nProblem synchronizing the notes of the new user map with id = " + new_user_map.id.to_s)
62 62 end
63 63
64   - ApiOperations::Common.log(:debug,nil,"Finished note synchronization for the new user map with id = " + user_map.id.to_s + " of the account with id = " + account.id.to_s)
  64 + ApiOperations::Common.log(:debug,nil,"Finished note synchronization for the new user map with id = " + new_user_map.id.to_s + " of the account with id = " + account.id.to_s)
65 65 else
66 66 begin
67 67 # get the feed of changed notes per contact of this Ringio account
@@ -78,7 +78,7 @@ def self.synchronize_account_process(account, user_map)
78 78 end
79 79
80 80
81   - def self.synchronize_user(user_feed)
  81 + def self.synchronize_new_user(user_feed)
82 82 begin
83 83 user_map = user_feed[0]
84 84 if user_map
@@ -162,7 +162,7 @@ def self.synchronize_contacts(account, user_feeds, rg_deleted_notes_ids)
162 162
163 163
164 164 # behaves like self.fetch_user_rg_feeds but just for the element of the array for this user map
165   - def self.fetch_individual_user_feed(user_map)
  165 + def self.fetch_individual_new_user_feed(user_map)
166 166 # get updated notes from Ringio
167 167 user_feed = user_map.account.all_rg_notes_feed.updated.inject([user_map,[]]) do |user_feed,rg_note_id|
168 168 rg_note = RingioAPI::Note.find rg_note_id
26 lib/api_operations/rings.rb
@@ -27,18 +27,18 @@ def self.synchronize_account(account, new_user_maps)
27 27 private
28 28
29 29
30   - def self.synchronize_account_process(account, user_map)
  30 + def self.synchronize_account_process(account, new_user_map)
31 31 # if there is a new user map
32   - if user_map
33   - ApiOperations::Common.log(:debug,nil,"Started ring synchronization for the new user map with id = " + user_map.id.to_s + " of the account with id = " + account.id.to_s)
  32 + if new_user_map
  33 + ApiOperations::Common.log(:debug,nil,"Started ring synchronization for the new user map with id = " + new_user_map.id.to_s + " of the account with id = " + account.id.to_s)
34 34
35 35 begin
36 36 # get the feed of changed rings per contact of this new user map from Ringio,
37 37 # we will not check for deleted rings, because they cannot be deleted
38 38 account_rg_feed = account.all_rg_rings_feed
39   - contact_rg_feeds = self.fetch_contact_rg_feeds(user_map,account_rg_feed,account)
  39 + contact_rg_feeds = self.fetch_contact_rg_feeds(new_user_map,account_rg_feed,account)
40 40 rescue Exception => e
41   - ApiOperations::Common.log(:error,e,"\nProblem fetching the changed rings for the new user map with id = " + user_map.id.to_s + " of the account with id = " + account.id.to_s)
  41 + ApiOperations::Common.log(:error,e,"\nProblem fetching the changed rings for the new user map with id = " + new_user_map.id.to_s + " of the account with id = " + account.id.to_s)
42 42 end
43 43 else
44 44 begin
@@ -54,8 +54,8 @@ def self.synchronize_account_process(account, user_map)
54 54
55 55 self.synchronize_contacts contact_rg_feeds
56 56
57   - if user_map
58   - ApiOperations::Common.log(:debug,nil,"Finished ring synchronization for the new user map with id = " + user_map.id.to_s + " of the account with id = " + account.id.to_s)
  57 + if new_user_map
  58 + ApiOperations::Common.log(:debug,nil,"Finished ring synchronization for the new user map with id = " + new_user_map.id.to_s + " of the account with id = " + account.id.to_s)
59 59 end
60 60 end
61 61
@@ -110,14 +110,14 @@ def self.synchronize_contacts(contact_rg_feeds)
110 110 # [0] => contact map
111 111 # [1] => updated Ringio rings for this contact map
112 112 # we will choose the author of the ring event note in Highrise as the owner of the contact
113   - def self.fetch_contact_rg_feeds(user_map, account_rg_feed, account)
  113 + def self.fetch_contact_rg_feeds(new_user_map, account_rg_feed, account)
114 114 account_rg_feed.updated.inject([]) do |contact_feeds,rg_ring_id|
115 115 rg_ring = RingioAPI::Ring.find rg_ring_id
116 116
117 117 if rg_ring.attributes['from_type'].present? && rg_ring.from_type == 'contact'
118   - self.process_rg_ring_new_user_map(user_map,rg_ring.from_id,contact_feeds,rg_ring,account)
  118 + self.process_rg_ring_user_map(new_user_map,rg_ring.from_id,contact_feeds,rg_ring,account)
119 119 elsif rg_ring.attributes['to_type'].present? && rg_ring.to_type == 'contact'
120   - self.process_rg_ring_new_user_map(user_map,rg_ring.to_id,contact_feeds,rg_ring,account)
  120 + self.process_rg_ring_user_map(new_user_map,rg_ring.to_id,contact_feeds,rg_ring,account)
121 121 end
122 122
123 123 contact_feeds
@@ -125,10 +125,10 @@ def self.fetch_contact_rg_feeds(user_map, account_rg_feed, account)
125 125 end
126 126
127 127
128   - def self.process_rg_ring_new_user_map(user_map, rg_contact_id, contact_feeds, rg_ring, account)
  128 + def self.process_rg_ring_user_map(new_user_map, rg_contact_id, contact_feeds, rg_ring, account)
129 129 # synchronize only notes of contacts already mapped for this account
130   - if user_map
131   - if (cm = ContactMap.find_by_user_map_id_and_rg_contact_id(user_map.id,rg_contact_id))
  130 + if new_user_map
  131 + if (cm = ContactMap.find_by_user_map_id_and_rg_contact_id(new_user_map.id,rg_contact_id))
132 132 self.process_rg_ring(cm,contact_feeds,rg_ring)
133 133 end
134 134 else

0 comments on commit 30f0e84

Please sign in to comment.
Something went wrong with that request. Please try again.