clark_kent 0.10.4 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/mailers/clark_kent/report_mailer.rb +8 -4
- data/app/models/clark_kent/report.rb +8 -2
- data/app/models/clark_kent/report_email.rb +3 -3
- data/app/views/clark_kent/report_mailer/report_run.html.erb +7 -2
- data/lib/clark_kent.rb +3 -1
- data/lib/clark_kent/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a055862b32f99723985e08f5f89b5919d4e606189db5ad144757d44f3ac3ac71
|
4
|
+
data.tar.gz: f1fe3d727f9d676af14d69ce17eef0ffb3b1a6273693af9671e739fbfa6ef88a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f813d2aabea50e64e02066d88b1a25751423d9f2560d45f2770d79710b6a4a1b5847e83db242bbff74b42a1b37758ac7cb27282e0ba31abce52da7bfc0911132
|
7
|
+
data.tar.gz: 184f74656189d0757d33b2b21ebe89bffa03985d2f54ebf209eea57585c226fb8f4f93c6e9da6dd9ccef586cc4fd236e42b9ceff8746989a1869a705db3f7e19
|
@@ -2,18 +2,22 @@ module ClarkKent
|
|
2
2
|
class ReportMailer < ActionMailer::Base
|
3
3
|
default from: 'reservations@invitedhome.com'
|
4
4
|
|
5
|
-
def report_run(report_id, user_id,
|
5
|
+
def report_run(report_id, user_id, report_accessor)
|
6
6
|
@report = Report.find(report_id)
|
7
|
-
@user = User.find(user_id)
|
7
|
+
@user = ::User.find(user_id)
|
8
8
|
@recipient_email = @user.email
|
9
|
-
|
9
|
+
if 'login_required' == ClarkKent.email_security
|
10
|
+
@report_filename = report_accessor
|
11
|
+
else
|
12
|
+
@report_download_url = report_accessor
|
13
|
+
end
|
10
14
|
@subject = "Your report #{@report.name} is ready"
|
11
15
|
mail(to: @recipient_email, subject: @subject)
|
12
16
|
end
|
13
17
|
|
14
18
|
def report_error(report_id, user_id, error_message)
|
15
19
|
@report = Report.find(report_id)
|
16
|
-
@user = User.find(user_id)
|
20
|
+
@user = ::User.find(user_id)
|
17
21
|
@recipient_email = @user.email
|
18
22
|
@error_message = error_message
|
19
23
|
@subject = "Your report #{@report.name} has a problem"
|
@@ -28,8 +28,10 @@ require 'aws-sdk-v1'
|
|
28
28
|
def self.send_report_to_s3(report_id, params)
|
29
29
|
report_class = params[:report_class].constantize if params[:report_class]
|
30
30
|
report_class ||= ::ClarkKent::Report
|
31
|
+
|
31
32
|
reportable = report_class.find(report_id)
|
32
|
-
|
33
|
+
is_email = 'ClarkKent::ReportEmail' == report_class.name
|
34
|
+
report = is_email ? reportable.report : reportable
|
33
35
|
query = reportable.get_query(params)
|
34
36
|
row_count = reportable.get_query(params, true)
|
35
37
|
bucket = AWS::S3::Bucket.new(ClarkKent.bucket_name)
|
@@ -74,7 +76,11 @@ require 'aws-sdk-v1'
|
|
74
76
|
report.browser_tab_id = params[:browser_tab_id]
|
75
77
|
report.broadcast_change
|
76
78
|
end
|
77
|
-
|
79
|
+
if is_email && 'login_required' == ClarkKent.email_security
|
80
|
+
params[:report_result_name]
|
81
|
+
else
|
82
|
+
report.report_result_url.to_s
|
83
|
+
end
|
78
84
|
end
|
79
85
|
|
80
86
|
def viable_report_columns
|
@@ -33,7 +33,7 @@ module ClarkKent
|
|
33
33
|
|
34
34
|
def send_emails
|
35
35
|
self.user_report_emails.each do |user_report_email|
|
36
|
-
ConeyIsland.submit(ClarkKent::ReportEmail, :send_email, instance_id: self.id, args: [user_report_email.user_id], timeout: 300, work_queue:
|
36
|
+
ConeyIsland.submit(ClarkKent::ReportEmail, :send_email, instance_id: self.id, args: [user_report_email.user_id], timeout: 300, work_queue: ClarkKent.work_queue)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -52,10 +52,10 @@ module ClarkKent
|
|
52
52
|
end
|
53
53
|
report_download_url = ClarkKent::Report.send_report_to_s3(self.id, params)
|
54
54
|
mail = ClarkKent::ReportMailer.report_run(self.report_id, user_id, report_download_url)
|
55
|
-
|
55
|
+
mail.deliver_now
|
56
56
|
rescue ClarkKent::ReportFilterError => e
|
57
57
|
mail = ClarkKent::ReportMailer.report_error(self.report_id, user_id, e.message)
|
58
|
-
|
58
|
+
mail.deliver_now
|
59
59
|
end
|
60
60
|
|
61
61
|
def report_filter_params
|
@@ -1,2 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% if @report_download_url %>
|
2
|
+
Click this link to download your report:
|
3
|
+
<a href="<%= @report_download_url %>"><%= @report.name %></a>
|
4
|
+
<% elsif @report_filename %>
|
5
|
+
Your report is ready to download. Log into your Amazon S3 account and download
|
6
|
+
<%= @report_filename %>.
|
7
|
+
<% end %>
|
data/lib/clark_kent.rb
CHANGED
@@ -5,7 +5,7 @@ require 'aws-sdk-v1'
|
|
5
5
|
|
6
6
|
module ClarkKent
|
7
7
|
mattr_accessor :resource_options, :user_class_name, :other_sharing_scopes, :base_controller,
|
8
|
-
:custom_report_links, :current_user_method
|
8
|
+
:custom_report_links, :current_user_method, :work_queue, :email_security
|
9
9
|
|
10
10
|
def self.bucket_name
|
11
11
|
@@bucket_name || "clark-kent"
|
@@ -20,6 +20,8 @@ module ClarkKent
|
|
20
20
|
@@base_controller = base_controller_name.constantize if base_controller_name.present?
|
21
21
|
@@custom_report_links = options[:custom_report_links] || []
|
22
22
|
@@current_user_method = options[:current_user_method]
|
23
|
+
@@work_queue = options[:work_queue]
|
24
|
+
@@email_security = options[:email_security]
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.user_class
|
data/lib/clark_kent/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clark_kent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|