motor-admin 0.2.8 → 0.2.9

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: 17e18a7f05b5872257978713dc9bb51c5c19823ec07eed5dd4e2a5035817ab96
4
- data.tar.gz: a1cc9b42cabbc9278a43abaad16a5987847b162b6e04177c25fbaa5438ff3bf8
3
+ metadata.gz: f810c064605d59e011ec3b01567e592951b09717fe98482b5602489b471d0935
4
+ data.tar.gz: 032b28c51dce430021d2dfda417e083d9fac2933041df82db95fd6fbf06d63bb
5
5
  SHA512:
6
- metadata.gz: 698d0a1d1b9ae1b2f4589decff0cc54fbae9c49a61a553504963ef71c8a02ecae656dd6a7a163cb28af4ee65155cff31b8240237b5ff6a58a0de76597beff2f4
7
- data.tar.gz: c07b294604ec27c76f35f55f69a0c592a7dd349a6b446efd724090c2eac1e07d71e24785ca4bdb80e960a51735e923bb62775c6b477c375446b19ae40185c505
6
+ metadata.gz: 6d9c6e98979b5e69bd91213b0f22ba8a5f9a892117cf0d6bcd65f6b2777fd6f75ee66e361e97efad275bc65c12bbcc994c064d4200ac75819de411e96340234b
7
+ data.tar.gz: 79670f3add6f53d94545f1d9cf68a0c6d200ef3ad5f461f08e70aec5d83869c4a9baea826328309b5c63bf148c0be87579399259b5fc3de473fed0fb60af5b2b
@@ -2,13 +2,19 @@
2
2
 
3
3
  module Motor
4
4
  class AlertsMailer < ApplicationMailer
5
+ SenderAddressNotSet = Class.new(StandardError)
6
+ SENDER_NOT_SET_ERROR_MESSAGE =
7
+ 'Please specify your sender address via MOTOR_ALERTS_FROM_ADDRESS environment variable'
8
+
5
9
  def alert_email(alert)
6
10
  @alert = alert
7
11
  @query_result = Queries::RunQuery.call(alert.query)
8
12
 
9
13
  return if @alert.preferences[:send_empty].blank? && @query_result.data.blank?
10
14
 
11
- attachments["#{alert.name.presence || 'data'}.csv"] = generate_csv(@query_result)
15
+ assign_attachment(@alert, @query_result)
16
+
17
+ raise SenderAddressNotSet, SENDER_NOT_SET_ERROR_MESSAGE unless from_address
12
18
 
13
19
  mail(
14
20
  from: from_address,
@@ -19,6 +25,10 @@ module Motor
19
25
 
20
26
  private
21
27
 
28
+ def assign_attachment(alert, query_result)
29
+ attachments["#{alert.name.presence || 'data'}.csv"] = generate_csv(query_result)
30
+ end
31
+
22
32
  def generate_csv(_query_result)
23
33
  rows = [@query_result.columns.pluck(:name)] + @query_result.data
24
34
 
@@ -32,7 +42,9 @@ module Motor
32
42
  from ||= mailer_config_from_address
33
43
  from ||= "reports@#{ENV['HOST'].delete_prefix('www.')}" if ENV['HOST'].present?
34
44
 
35
- from || 'reports@example.com'
45
+ from ||= 'reports@example.com' if Rails.env.development?
46
+
47
+ from
36
48
  end
37
49
 
38
50
  def application_mailer_default_from
@@ -264,3 +264,4 @@ en:
264
264
  add_database: Add Database
265
265
  audio: Audio
266
266
  video: Video
267
+ display_column: Display column
@@ -264,6 +264,7 @@ es:
264
264
  add_database: Añadir base de datos
265
265
  audio: Audio
266
266
  video: Video
267
+ display_column: Columna de visualización
267
268
  i:
268
269
  locale: es
269
270
  select:
@@ -260,6 +260,7 @@ pt:
260
260
  write_only: "Somente gravação"
261
261
  audio: Áudio
262
262
  video: Vídeo
263
+ display_column: Coluna de exibição
263
264
  i:
264
265
  locale: pt
265
266
  select:
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ if Rails::VERSION::MAJOR == 7
4
+ module ArLazyPreload
5
+ module Relation
6
+ def preload_associations(records)
7
+ preload = preload_values
8
+ preload += includes_values unless eager_loading?
9
+ scope = strict_loading_value ? ActiveRecord::Relation::StrictLoadingScope : nil
10
+ preload.each do |associations|
11
+ preloader_associations = ActiveRecord::Associations::Preloader.new(records: records,
12
+ associations: associations,
13
+ scope: scope).call
14
+
15
+ preloader_associations.each do |preloader_association|
16
+ handle_preloaded_records(preloader_association.preloaded_records)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -23,3 +23,4 @@ require_relative './active_record_utils/active_storage_blob_patch'
23
23
  require_relative './active_record_utils/active_record_filter_patch'
24
24
  require_relative './active_record_utils/active_record_connection_column_patch'
25
25
  require_relative './active_record_utils/action_text_attribute_patch'
26
+ require_relative './active_record_utils/ar_lazy_preload_patch'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Motor
4
4
  module Resources
5
- RESOURCE_ATTRS = %w[display_name icon custom_sql visible].freeze
5
+ RESOURCE_ATTRS = %w[display_name display_column icon custom_sql visible].freeze
6
6
  COLUMN_ATTRS = %w[name display_name column_type access_type default_value reference virtual format].freeze
7
7
  ASSOCIATION_ATTRS = %w[name display_name model_name icon visible foreign_key primary_key options virtual
8
8
  polymorphic slug].freeze
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.2.8'
4
+ VERSION = '0.2.9'
5
5
  end
@@ -2601,9 +2601,9 @@
2601
2601
  "icons/zoom-out.svg.gz": "icons/zoom-out.svg.gz",
2602
2602
  "icons/zoom-question.svg": "icons/zoom-question.svg",
2603
2603
  "icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
2604
- "main-c332e3fdad0c8e350a4c.css.gz": "main-c332e3fdad0c8e350a4c.css.gz",
2605
- "main-c332e3fdad0c8e350a4c.js.LICENSE.txt": "main-c332e3fdad0c8e350a4c.js.LICENSE.txt",
2606
- "main-c332e3fdad0c8e350a4c.js.gz": "main-c332e3fdad0c8e350a4c.js.gz",
2607
- "main.css": "main-c332e3fdad0c8e350a4c.css",
2608
- "main.js": "main-c332e3fdad0c8e350a4c.js"
2604
+ "main-440589ed06b181856305.css.gz": "main-440589ed06b181856305.css.gz",
2605
+ "main-440589ed06b181856305.js.LICENSE.txt": "main-440589ed06b181856305.js.LICENSE.txt",
2606
+ "main-440589ed06b181856305.js.gz": "main-440589ed06b181856305.js.gz",
2607
+ "main.css": "main-440589ed06b181856305.css",
2608
+ "main.js": "main-440589ed06b181856305.js"
2609
2609
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -165,6 +165,7 @@ files:
165
165
  - lib/motor/active_record_utils/active_record_filter_patch.rb
166
166
  - lib/motor/active_record_utils/active_storage_blob_patch.rb
167
167
  - lib/motor/active_record_utils/active_storage_links_extension.rb
168
+ - lib/motor/active_record_utils/ar_lazy_preload_patch.rb
168
169
  - lib/motor/active_record_utils/defined_scopes_extension.rb
169
170
  - lib/motor/active_record_utils/fetch_methods.rb
170
171
  - lib/motor/active_record_utils/types.rb
@@ -1523,8 +1524,8 @@ files:
1523
1524
  - ui/dist/icons/zoom-money.svg.gz
1524
1525
  - ui/dist/icons/zoom-out.svg.gz
1525
1526
  - ui/dist/icons/zoom-question.svg.gz
1526
- - ui/dist/main-c332e3fdad0c8e350a4c.css.gz
1527
- - ui/dist/main-c332e3fdad0c8e350a4c.js.gz
1527
+ - ui/dist/main-440589ed06b181856305.css.gz
1528
+ - ui/dist/main-440589ed06b181856305.js.gz
1528
1529
  - ui/dist/manifest.json
1529
1530
  homepage:
1530
1531
  licenses: