subj_models 0.5.2 → 0.5.3

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: ffa0c2a11913afea11257be5d268b5b4efb9bcf8
4
- data.tar.gz: 7d314c1212c40c3d8edd8551791403c0028e92c9
3
+ metadata.gz: 958eb3c88e4357f059d9a8927db46350878a4f17
4
+ data.tar.gz: 582937b4853a504f34e6a33f21ec3232dfa19094
5
5
  SHA512:
6
- metadata.gz: 6b5af94dcf10b00680b5262e55f9ba7afec7a8cc3aa20ff42a11d250944a21d4decbbc35a4d6a5c5f1b5541631c58f5341c60133838f558f9e3c46ea84d4b197
7
- data.tar.gz: d8c6803edd8361cb13aeeb417c684107c06186b6cea9bc5170356d17f25f56d99f0c9a80ac8f4ef5a122216b39f962a6cd3a8eb615937a5c046b54772f993fa1
6
+ metadata.gz: e693532fbe0e4c003034b410e54b5032fdaae5c18da50d38e42ecee6e5a71f42d1330dd1845c372ef91c5637980547077ddf5616fa25e55badc99054128906f6
7
+ data.tar.gz: 7c44584ddde51d6ddaf9f4fd782138ab4d919406a4697d01c414f25277184f8d9f4bb93c6dd1f31898a7f2f808d8f6395c7c5497d0a3f63bbe61a56777b970f9
@@ -15,7 +15,6 @@ module SubjModels
15
15
 
16
16
  enum faq_type: FAQ_TYPES
17
17
 
18
- after_create :notify_manager
19
18
  after_save :notify_user
20
19
 
21
20
  validates :question, presence: true, allow_blank: false,
@@ -42,10 +41,6 @@ module SubjModels
42
41
 
43
42
  private
44
43
 
45
- def notify_manager
46
- FaqMailer.notify_manager(self).deliver
47
- end
48
-
49
44
  def notify_user
50
45
  FaqMailer.notify_user(self).deliver if send_to_user
51
46
  end
@@ -52,6 +52,8 @@ module SubjModels
52
52
  .last
53
53
  end
54
54
 
55
+ scope :has_items, -> { joins(:order_items).where.not(order_items: {order_id: nil}).uniq }
56
+
55
57
  end
56
58
 
57
59
  end
@@ -11,7 +11,6 @@ module SubjModels
11
11
  include SubjModels::ComprisingExternalId
12
12
 
13
13
  belongs_to :order
14
- belongs_to :city
15
14
 
16
15
  validates :privat_bank_address, presence: true
17
16
 
@@ -14,8 +14,8 @@ module SubjModels
14
14
 
15
15
  include SubjModels::ComprisingExternalId
16
16
 
17
- before_destroy :update_nomenclature_popularity
18
- after_create :update_nomenclature_popularity
17
+ before_destroy :decrease_nomenclature_popularity
18
+ after_create :increase_nomenclature_popularity
19
19
 
20
20
  enum item_type: ITEM_TYPES
21
21
 
@@ -43,6 +43,22 @@ module SubjModels
43
43
 
44
44
  private
45
45
 
46
+ def increase_nomenclature_popularity
47
+ if nomenclature
48
+ current_popularity = (nomenclature.popularity && nomenclature.popularity > 0) ? nomenclature.popularity : 0
49
+ nomenclature.update(popularity: current_popularity + item_count)
50
+ end
51
+ end
52
+
53
+ def decrease_nomenclature_popularity
54
+ if nomenclature
55
+ current_popularity = (nomenclature.popularity && nomenclature.popularity > item_count) ? nomenclature.popularity : item_count
56
+ nomenclature.update(popularity: current_popularity - item_count)
57
+ end
58
+ end
59
+
60
+
61
+
46
62
  def update_nomenclature_popularity
47
63
  if nomenclature
48
64
  current_popularity = (nomenclature.popularity && nomenclature.popularity > 0) ? nomenclature.popularity : 0
@@ -1,3 +1,3 @@
1
1
  module SubjModels
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subj_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denys Dvoriashyn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-28 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler