contact_sync 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fca10e547dcbdc61eb98446899ab823c1f3ea86
4
- data.tar.gz: 00796a313348b0b656c837eb5c0d1113d6a62f12
3
+ metadata.gz: 612e1896eed72d3d5b06580381ec3795bc3b9cba
4
+ data.tar.gz: 835712bb3edfb4a72c5a5276c856ddee426dc65d
5
5
  SHA512:
6
- metadata.gz: 8fdcc62350ebbea362a642950f7c98ee536c2c1c353e543813a8513ce5e9c5636fc455e5f4b7da5d8c4959658c7896e72d9d85216fff7df987297c9ed967cb38
7
- data.tar.gz: fbd6e245d7c53c89f17663c964f7987efb0f8301a2e82195ee6582b167aa7ee76f821689f1c5710d325e955785361259ac86dc4585e222a0f88383b6e0189a8b
6
+ metadata.gz: 935692a079c125869b94965a3a600f0ce327aa76de011528415cf472f2f1f5fc5c2e8ce04fc848b4ae0d9fc61e3ecabeb34f2ebb7c9f7d75e8fe5dfd08dad793
7
+ data.tar.gz: f35d1125a44869a070fa04e054932c2b0f8b8a5926a24f4346c1ec78e6ace87b8377944f0d77e9f219249a1ba1dadcd398956925a03f8397a15cb383b9550c3e
@@ -83,26 +83,56 @@ module ContactSync
83
83
  return result
84
84
  end
85
85
 
86
+
86
87
  def matched_contacts
87
- matched_contacts = []
88
- user_phones = []
89
- user_emails = []
90
- self.contacts.each do |con|
91
- user_phones.concat con.phones
92
- user_emails.concat con.emails
93
- end
88
+ matched_users = []
89
+ other_contacts = []
94
90
 
95
- user_phones.each do |phone|
96
- u = User.where(encrypted_number: phone.number.encrypt(:symmetric)).limit(1).first
97
- matched_contacts << u.id unless u.blank?
98
- end
99
- user_emails.each do |mail|
100
- u = User.where(email: mail.email).limit(1).first
101
- matched_contacts << u.id unless u.blank?
91
+ self.contacts.includes([:emails, :phones]) do |aKon|
92
+ aKon.phones.each do |ph|
93
+ matches = false
94
+ u = User.where(encrypted_number: ph.number.encrypt(:symmetric)).limit(1).first
95
+ if !u.blank?
96
+ matches = true
97
+ matched_users << {user: u.id, phone: ph.id, contact: aKon.id}
98
+ end
99
+ end
100
+ aKon.emails.each do |em|
101
+ u = User.where(email: mail.email).limit(1).first
102
+ if !u.blank?
103
+ matches = true
104
+ matched_users << {user: u.id, email: em.id, contact: aKon.id}
105
+ end
106
+ end
107
+ other_contacts << aKon if !matches
102
108
  end
103
- return matched_contacts
104
109
  end
105
110
 
111
+
112
+
113
+ # def matched_contacts
114
+ # matched_contacts = []
115
+ # user_phones = []
116
+ # user_emails = []
117
+ # self.contacts.each do |con|
118
+ # user_phones.concat con.phones
119
+ # user_emails.concat con.emails
120
+ # end
121
+ #
122
+ # user_phones.each do |phone|
123
+ # u = User.where(encrypted_number: phone.number.encrypt(:symmetric)).limit(1).first
124
+ # matched_contacts << u.id unless u.blank?
125
+ # end
126
+ # user_emails.each do |mail|
127
+ # u = User.where(email: mail.email).limit(1).first
128
+ # if !u.blank?
129
+ # matched_contacts << u.id
130
+ # end
131
+ # end
132
+ # other_contacts = self.contacts.collect(&:id) &
133
+ # return {app_users: matched_contacts, other_users: self.contacts}
134
+ # end
135
+ #
106
136
  private
107
137
  def contact_params(aContact)
108
138
  aContact.permit(:composite_name, :first_name, :middle_name, :last_name, :prefix, :suffix, :nickname, :job_title, :department, :organization, :birthdate, :note, :creation_date, :modification_date, :record_id)
@@ -1,3 +1,3 @@
1
1
  module ContactSync
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contact_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saad Masood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-26 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails