motor-admin 0.1.51 → 0.1.52

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
  SHA256:
3
- metadata.gz: e36dd42cf57e4b17340faac8ac91874566a5920dda51cd113b7e8ccb62c82756
4
- data.tar.gz: d72fddef3740647b12ac5723e3512290b0bee08ebbba4448f2b214d6c0dffb2d
3
+ metadata.gz: 8798474d7c7dc20d6410dd00f13950997be5e3f5d67e1d2585a57af92cd8db10
4
+ data.tar.gz: 90fcc0b1835fe56b78ecfcc28de03f9d4397b213f6e499afc626c3f4d13b1ef9
5
5
  SHA512:
6
- metadata.gz: 0efa0fd91dff6a962b367acba95a56335231f11331ba37170ded4324bc370cf85fc239c2a816a48fc293bd742de60d36d4cf5e4947627578530d8776e0e71bca
7
- data.tar.gz: f106c14a7453c8db2d5754ef1ad9f6e99ec1fef33a58dea6779bdb031eabf3e6adce90ca6f2227ac222e0603b982aa06532d97520351afe42f45a913f0fb3d22
6
+ metadata.gz: c3a34e36e74e5004508e420ba4cdf95e2784d52647dfefccb64fc078b2785cbdd42a7aad84ca41f4c86e2c680b76516f219a41739b7d19601798dda4c9319e06
7
+ data.tar.gz: 727c31fafba431b69e3206d0fb2cff568171760cd43b36b9a42e97a356d5e344c7cacb069c5e9e79899e0fa804f39fd122ae14e30aece4cb77ca64de31620c5f
@@ -12,10 +12,12 @@ module Motor
12
12
  end
13
13
  end
14
14
 
15
- rescue_from StandardError do |e|
16
- Rails.logger.error(e)
15
+ unless Rails.env.test?
16
+ rescue_from StandardError do |e|
17
+ Rails.logger.error(e)
17
18
 
18
- render json: { errors: [e.message] }, status: :internal_server_error
19
+ render json: { errors: [e.message] }, status: :internal_server_error
20
+ end
19
21
  end
20
22
 
21
23
  def current_ability
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Motor
4
4
  class AssetsController < ActionController::Metal
5
- CACHE_STORE = ActiveSupport::Cache::MemoryStore.new(coder: ActiveSupport::Cache::NullCoder)
5
+ CACHE_STORE = ActiveSupport::Cache::MemoryStore.new
6
6
 
7
7
  GZIP_TYPES = [
8
8
  'application/javascript',
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Motor
4
4
  class IconsController < ApiBaseController
5
- CACHE_STORE = ActiveSupport::Cache::MemoryStore.new(coder: ActiveSupport::Cache::NullCoder)
5
+ CACHE_STORE = ActiveSupport::Cache::MemoryStore.new
6
6
 
7
7
  def index
8
8
  data = CACHE_STORE.fetch('icons') do
@@ -13,6 +13,10 @@ module Motor
13
13
  super(**hash.with_indifferent_access.slice(*KEYWORD_ARGS).symbolize_keys)
14
14
  end
15
15
 
16
+ def create_after_upload!(hash)
17
+ super(**hash.with_indifferent_access.slice(*KEYWORD_ARGS).symbolize_keys)
18
+ end
19
+
16
20
  def create_after_unfurling!(hash)
17
21
  super(**hash.with_indifferent_access.slice(*KEYWORD_ARGS).symbolize_keys)
18
22
  end
data/lib/motor/admin.rb CHANGED
@@ -66,13 +66,12 @@ module Motor
66
66
  end
67
67
 
68
68
  initializer 'motor.active_storage.extensions' do
69
- ActiveSupport.on_load(:active_storage_attachment) do
70
- ActiveStorage::Attachment.include(Motor::ActiveRecordUtils::ActiveStorageLinksExtension)
71
- end
69
+ next unless defined?(ActiveStorage::Engine)
72
70
 
73
- ActiveSupport.on_load(:active_storage_blob) do
74
- ActiveStorage::Blob.singleton_class.prepend(Motor::ActiveRecordUtils::ActiveStorageBlobPatch)
75
- end
71
+ ActiveStorage::Engine.eager_load!
72
+
73
+ ActiveStorage::Attachment.include(Motor::ActiveRecordUtils::ActiveStorageLinksExtension)
74
+ ActiveStorage::Blob.singleton_class.prepend(Motor::ActiveRecordUtils::ActiveStorageBlobPatch)
76
75
  end
77
76
  end
78
77
  end
@@ -3,8 +3,7 @@
3
3
  module Motor
4
4
  module Alerts
5
5
  module ScheduledAlertsCache
6
- CACHE_STORE = ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes,
7
- coder: ActiveSupport::Cache::NullCoder)
6
+ CACHE_STORE = ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes)
8
7
 
9
8
  module_function
10
9
 
@@ -13,7 +13,9 @@ module Motor
13
13
  arel_order = build_arel_order(rel.klass, param)
14
14
  join_params = build_join_params(rel.klass, param)
15
15
 
16
- rel.reorder(arel_order).left_joins(join_params)
16
+ rel = rel.left_joins(join_params) if join_params.present?
17
+
18
+ rel.reorder(arel_order)
17
19
  end
18
20
 
19
21
  def build_join_params(_model, param)
@@ -7,8 +7,7 @@ module Motor
7
7
  if Motor.development?
8
8
  ActiveSupport::Cache::NullStore.new
9
9
  else
10
- ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes,
11
- coder: ActiveSupport::Cache::NullCoder)
10
+ ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes)
12
11
  end
13
12
 
14
13
  module_function
@@ -3,8 +3,7 @@
3
3
  module Motor
4
4
  module Configs
5
5
  module LoadFromCache
6
- CACHE_STORE = ActiveSupport::Cache::MemoryStore.new(size: 10.megabytes,
7
- coder: ActiveSupport::Cache::NullCoder)
6
+ CACHE_HASH = HashWithIndifferentAccess.new
8
7
 
9
8
  module_function
10
9
 
@@ -57,10 +56,18 @@ module Motor
57
56
  end
58
57
  end
59
58
 
60
- def maybe_fetch_from_cache(type, cache_key, &block)
59
+ def maybe_fetch_from_cache(type, cache_key)
61
60
  return yield unless cache_key
62
61
 
63
- CACHE_STORE.fetch(type + cache_key.to_s, &block)
62
+ if CACHE_HASH[type] && CACHE_HASH[type][:key] == cache_key
63
+ CACHE_HASH[type][:value]
64
+ else
65
+ result = yield
66
+
67
+ CACHE_HASH[type] = { key: cache_key, value: result }
68
+
69
+ result
70
+ end
64
71
  end
65
72
 
66
73
  def load_cache_keys
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.1.51'
4
+ VERSION = '0.1.52'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.51
4
+ version: 0.1.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka