usman 0.3.28 → 0.3.29

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: beda5a8898223f4c9111aab181ca6101fdd95d48
4
- data.tar.gz: a4b060c7a6dccbbd5c36e4f1ec399f09e4965751
3
+ metadata.gz: 9839d730797d07337b7149badcdbf025934f356e
4
+ data.tar.gz: 73c00478cf0c8caec5ed7f2de7f59badbf33265c
5
5
  SHA512:
6
- metadata.gz: 9573d3001f302905d4af8f87c363a197fd40a7e52b13d3b0d93e2e1029645a436a113ff1929f7550bbca19f438163f628b1ea4940c48c1c66ddeeee8a08aa768
7
- data.tar.gz: 3841203c69049d93f63e92d1881bbddddb9a69657959d578aaff90c45d686b070ac4bf47e44321a5f0c640559e49b1641dd670654ac6f425f473eb4817b02d07
6
+ metadata.gz: 32981f73b6c4fe759f6e15d818b4376749a8c8b3fc9d2a4316bcbf9d403528cf5a1ce3c368ded4f2b4db12217ebc44755759a8574da2b91d09a57ace24f26dfc
7
+ data.tar.gz: c32f1463a7b3248d2b2cbd39996cc3a545afe2d11b7fb04d6b41437495b92048d294b8f47116d6d7630edef0dfbe7fb293df4c764c922336a6fcfec74e5646ef
@@ -21,11 +21,8 @@ module Usman
21
21
  contact.name = cnt["name"]
22
22
  contact.account_type = cnt["account_type"]
23
23
  contact.email = cnt["email"]
24
- contact.contact_number_1 = cnt["contact_number_1"]
25
- contact.contact_number_2 = cnt["contact_number_2"]
26
- contact.contact_number_3 = cnt["contact_number_3"]
27
- contact.contact_number_4 = cnt["contact_number_4"]
28
-
24
+ contact.contact_number = cnt["contact_number"]
25
+
29
26
  contact.owner = @current_user
30
27
  contact.done_deal_user = contact.get_done_deal_user
31
28
  contact.registration = @current_registration
@@ -106,7 +103,7 @@ module Usman
106
103
  private
107
104
 
108
105
  def permitted_params
109
- params.permit(:name, :account_type, :email, :address, :contact_number_1, :contact_number_2, :contact_number_3, :contact_number_4)
106
+ params.permit(:name, :account_type, :email, :address, :contact_number)
110
107
  end
111
108
 
112
109
  end
@@ -230,16 +230,14 @@ module Usman
230
230
  "account_type": "com.mollywood",
231
231
  "email": "mohanlal@gmail.com",
232
232
  "address": "xyz, str, efg",
233
- "contact_number_1": "87393993884",
234
- "contact_number_2":"9846557465"
233
+ "contact_number": "87393993884"
235
234
  },
236
235
  {
237
236
  "name": "Mammukka",
238
237
  "account_type": "com.mollywood1",
239
238
  "email": "mammukka@gmail.com",
240
239
  "address": "xyz, str, efg",
241
- "contact_number_1": "7046338475",
242
- "contact_number_2":"8086500502"
240
+ "contact_number": "7046338475"
243
241
  }
244
242
  ]',
245
243
  default: ""
@@ -17,10 +17,7 @@ class Usman::Contact < Usman::ApplicationRecord
17
17
  format: /\A(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})\z/i
18
18
  validates :address, length: {maximum: 512}
19
19
 
20
- validates :contact_number_1, presence: true, length: {maximum: 24}
21
- validates :contact_number_2, length: {maximum: 24}
22
- validates :contact_number_3, length: {maximum: 24}
23
- validates :contact_number_4, length: {maximum: 24}
20
+ validates :contact_number, presence: true, length: {maximum: 24}
24
21
 
25
22
  # ------------------
26
23
  # Class Methods
@@ -32,10 +29,7 @@ class Usman::Contact < Usman::ApplicationRecord
32
29
  # >>> Contact.search(query)
33
30
  # => ActiveRecord::Relation object
34
31
  scope :search, lambda {|query| where("LOWER(contacts.name) LIKE LOWER('%#{query}%') OR
35
- LOWER(contacts.contact_number_1) LIKE LOWER('%#{query}%') OR
36
- LOWER(contacts.contact_number_2) LIKE LOWER('%#{query}%') OR
37
- LOWER(contacts.contact_number_3) LIKE LOWER('%#{query}%') OR
38
- LOWER(contacts.contact_number_4) LIKE LOWER('%#{query}%') OR
32
+ LOWER(contacts.contact_number) LIKE LOWER('%#{query}%') OR
39
33
  LOWER(contacts.email) LIKE LOWER('%#{query}%') OR
40
34
  LOWER(contacts.account_type) LIKE LOWER('%#{query}%')")}
41
35
 
@@ -68,10 +62,13 @@ class Usman::Contact < Usman::ApplicationRecord
68
62
  "#{self.name}"
69
63
  end
70
64
 
65
+ def parse_phone_number(num)
66
+ num.gsub(' ','').gsub('(','').gsub(')','').gsub('-','').strip
67
+ end
68
+
71
69
  def get_done_deal_user
72
- arr = [self.contact_number_1, self.contact_number_2, self.contact_number_3, self.contact_number_4].compact.uniq
73
- return if arr.first.nil?
74
- reg = Registration.where("CONCAT_WS('', dialing_prefix, mobile_number) IN (?)", arr).first
70
+ formatted_number = parse_phone_number(self.contact_number)
71
+ reg = Registration.where("CONCAT_WS('', dialing_prefix, mobile_number) = ?", formatted_number).first
75
72
  return reg && reg.user ? reg.user : nil
76
73
  end
77
74
 
@@ -1,6 +1,6 @@
1
1
  class ContactSerializer < ActiveModel::Serializer
2
2
  include NullAttributeReplacer
3
- attributes :id, :name, :account_type, :email, :address, :contact_number_1, :contact_number_2, :contact_number_3, :contact_number_4
3
+ attributes :id, :name, :account_type, :email, :address, :contact_number, :done_deal_user_id
4
4
 
5
5
  has_one :profile_picture, class_name: "Image::ProfilePicture", serializer: ProfilePictureSerializer do
6
6
  if object.done_deal_user && object.done_deal_user.profile_picture
@@ -22,10 +22,7 @@ api_output = <<-eos
22
22
  "account_type": "com.mollywood",
23
23
  "email": "mohanlal@gmail.com",
24
24
  "address": "",
25
- "contact_number_1": "87393993884",
26
- "contact_number_2": "9846557465",
27
- "contact_number_3": "",
28
- "contact_number_4": "",
25
+ "contact_number": "87393993884"
29
26
  "profile_picture": {
30
27
  "id": "",
31
28
  "created_at": "",
@@ -40,10 +37,7 @@ api_output = <<-eos
40
37
  "account_type": "com.mollywood1",
41
38
  "email": "mammukka@gmail.com",
42
39
  "address": "",
43
- "contact_number_1": "808650052",
44
- "contact_number_2": "7488374657",
45
- "contact_number_3": "",
46
- "contact_number_4": "",
40
+ "contact_number": "808650052"
47
41
  "profile_picture": {
48
42
  "id": "",
49
43
  "created_at": "",
@@ -14,16 +14,14 @@ POST #{request.base_url}/api/v1/contacts/sync
14
14
  "account_type": "com.mollywood",
15
15
  "email": "san@gmail.com",
16
16
  "address": "xyz, str, efg",
17
- "contact_number_1": "87393993884",
18
- "contact_number_2":"9846557465"
17
+ "contact_number": "87393993884"
19
18
  },
20
19
  {
21
20
  "name": "arjun",
22
21
  "account_type": "com.mollywood1",
23
22
  "email": "arj@gmail.com",
24
23
  "address": "xyz, str, efg",
25
- "contact_number_1": "77777777",
26
- "contact_number_2":"999999999"
24
+ "contact_number": "77777777"
27
25
  }
28
26
  ]
29
27
  }
@@ -14,16 +14,14 @@ POST #{request.base_url}/api/v1/contacts/sync
14
14
  "account_type": "com.mollywood",
15
15
  "email": "san@gmail.com",
16
16
  "address": "xyz, str, efg",
17
- "contact_number_1": "87393993884",
18
- "contact_number_2":"9846557465"
17
+ "contact_number": "87393993884"
19
18
  },
20
19
  {
21
20
  "name": "arjun",
22
21
  "account_type": "com.mollywood1",
23
22
  "email": "arj@gmail.com",
24
23
  "address": "xyz, str, efg",
25
- "contact_number_1": "77777777",
26
- "contact_number_2":"999999999"
24
+ "contact_number": "77777777"
27
25
  }
28
26
  ]
29
27
  }
@@ -21,10 +21,7 @@ api_output = <<-eos
21
21
  "account_type": "com.mollywood",
22
22
  "email": "mohanlal@gmail.com",
23
23
  "address": "",
24
- "contact_number_1": "87393993884",
25
- "contact_number_2": "9846557465",
26
- "contact_number_3": "",
27
- "contact_number_4": "",
24
+ "contact_number": "87393993884"
28
25
  "profile_picture": {
29
26
  "id": "",
30
27
  "created_at": "",
@@ -0,0 +1,7 @@
1
+ class CorrectContacts < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :contacts, :contact_number, :string, :null => false, :limit=>24
4
+ Usman::Contact.update_all("contact_number = contact_number_1")
5
+ remove_column :contacts, :contact_number_1
6
+ end
7
+ end
data/lib/usman/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Usman
2
- VERSION = '0.3.28'
2
+ VERSION = '0.3.29'
3
3
  end
@@ -9,7 +9,7 @@ FactoryGirl.define do
9
9
  name "Some Name"
10
10
  account_type "com.google"
11
11
 
12
- contact_number_1 "9912345678"
12
+ contact_number "9912345678"
13
13
  end
14
14
 
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.28
4
+ version: 0.3.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - kpvarma
@@ -604,6 +604,7 @@ files:
604
604
  - db/migrate/20170929083235_change_disabled_to_removed_features.rb
605
605
  - db/migrate/20170929083236_add_country_city_to_users.rb
606
606
  - db/migrate/20171124071245_create_contacts.rb
607
+ - db/migrate/20171212094209_correct_contacts.rb
607
608
  - lib/tasks/usman/data.rake
608
609
  - lib/tasks/usman/master_data.rake
609
610
  - lib/temp/features.rake