comable-core 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/comable/category.rb +6 -0
- data/app/models/comable/image.rb +1 -1
- data/app/models/comable/product.rb +16 -1
- data/app/models/comable/stock.rb +1 -1
- data/app/models/comable/variant.rb +1 -1
- data/db/migrate/20151129213103_add_product_id_index_to_comable_variants.rb +5 -0
- data/db/migrate/20151129213205_add_variant_id_index_to_comable_stocks.rb +5 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ef459f5170d6bf67d798f586b4fb15799935358
|
4
|
+
data.tar.gz: 2b509ef0d762a5369d1210ab3c29a904fe33f5c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba17a422dda10ebe99a4c5088349dc68de06f427b950b18e0660c95765789a8f59b6ae5afdd702e263168b4e5bf142e7ef654124b80beb380cf9a879bb97cf11
|
7
|
+
data.tar.gz: 26a44a40cafe32242b38497061234e8118db9980e75124f9e1bcdc42e685edb03e42ecf0607bea9ead7a63c418283d44515b1309f9b458e3a5ccedf974205da3
|
@@ -6,6 +6,8 @@ module Comable
|
|
6
6
|
|
7
7
|
default_scope -> { order('position ASC') }
|
8
8
|
|
9
|
+
after_save :touch_all_products
|
10
|
+
|
9
11
|
DEFAULT_PATH_NAME_DELIMITER = ' > '
|
10
12
|
|
11
13
|
class << self
|
@@ -68,5 +70,9 @@ module Comable
|
|
68
70
|
restore_from_jstree!(node['children'], category)
|
69
71
|
end
|
70
72
|
end
|
73
|
+
|
74
|
+
def touch_all_products
|
75
|
+
products.update_all(updated_at: Time.now)
|
76
|
+
end
|
71
77
|
end
|
72
78
|
end
|
data/app/models/comable/image.rb
CHANGED
@@ -8,7 +8,7 @@ module Comable
|
|
8
8
|
|
9
9
|
has_many :variants, class_name: Comable::Variant.name, inverse_of: :product, dependent: :destroy
|
10
10
|
has_many :images, -> { order(:id) }, class_name: Comable::Image.name, dependent: :destroy
|
11
|
-
has_and_belongs_to_many :categories, class_name: Comable::Category.name, join_table: :comable_products_categories
|
11
|
+
has_and_belongs_to_many :categories, class_name: Comable::Category.name, join_table: :comable_products_categories, after_add: :touch_updated_at, after_remove: :touch_updated_at
|
12
12
|
|
13
13
|
accepts_nested_attributes_for :variants, allow_destroy: true
|
14
14
|
accepts_nested_attributes_for :images, allow_destroy: true
|
@@ -24,6 +24,15 @@ module Comable
|
|
24
24
|
|
25
25
|
PREVIEW_SESSION_KEY = :preview_product
|
26
26
|
|
27
|
+
class << self
|
28
|
+
def cache_key
|
29
|
+
page = all.current_page if all.respond_to? :current_page
|
30
|
+
maximum_updated_at = maximum(:updated_at)
|
31
|
+
timestamp = maximum_updated_at.utc.to_s(cache_timestamp_format) if maximum_updated_at
|
32
|
+
"#{model_name.cache_key}/all-#{[page, timestamp, count].compact.join('-')}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
27
36
|
def image_url
|
28
37
|
image = images.first
|
29
38
|
return image.url if image
|
@@ -109,5 +118,11 @@ module Comable
|
|
109
118
|
deprecate :code, deprecator: Comable::Deprecator.instance
|
110
119
|
deprecate :code=, deprecator: Comable::Deprecator.instance
|
111
120
|
deprecate :option_types_attributes=, deprecator: Comable::Deprecator.instance
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def touch_updated_at(_category)
|
125
|
+
touch if persisted?
|
126
|
+
end
|
112
127
|
end
|
113
128
|
end
|
data/app/models/comable/stock.rb
CHANGED
@@ -10,7 +10,7 @@ module Comable
|
|
10
10
|
include Comable::Liquidable
|
11
11
|
include Comable::Stock::Csvable
|
12
12
|
|
13
|
-
belongs_to :variant, class_name: Comable::Variant.name, inverse_of: :stocks
|
13
|
+
belongs_to :variant, class_name: Comable::Variant.name, inverse_of: :stocks, touch: true
|
14
14
|
belongs_to :stock_location, class_name: Comable::StockLocation.name
|
15
15
|
|
16
16
|
#
|
@@ -3,7 +3,7 @@ module Comable
|
|
3
3
|
include Comable::Ransackable
|
4
4
|
include Comable::Variant::Quantifier
|
5
5
|
|
6
|
-
belongs_to :product, class_name: Comable::Product.name, inverse_of: :variants
|
6
|
+
belongs_to :product, class_name: Comable::Product.name, inverse_of: :variants, touch: true
|
7
7
|
has_many :stocks, class_name: Comable::Stock.name, inverse_of: :variant, dependent: :destroy
|
8
8
|
|
9
9
|
has_and_belongs_to_many :option_values, -> { order(:option_type_id, :created_at, :id) }, class_name: Comable::OptionValue.name, join_table: :comable_variants_option_values
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comable-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YOSHIDA Hiroki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -375,6 +375,8 @@ files:
|
|
375
375
|
- db/migrate/20151013082845_remove_null_option_of_shipment_method_id_on_comable_shipments.rb
|
376
376
|
- db/migrate/20151013194926_add_guest_token_index_to_comable_orders.rb
|
377
377
|
- db/migrate/20151112102452_add_draft_to_comable_orders.rb
|
378
|
+
- db/migrate/20151129213103_add_product_id_index_to_comable_variants.rb
|
379
|
+
- db/migrate/20151129213205_add_variant_id_index_to_comable_stocks.rb
|
378
380
|
- db/seeds.rb
|
379
381
|
- db/seeds/comable/users.rb
|
380
382
|
- lib/comable/core.rb
|