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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c15055012528a4868ad2f0c5c2c5755f99f36e20b5f6997a1acd7b92fa0074dd
4
- data.tar.gz: 1063fac92e5307544e29fc19c2d2a57dc75c380fd84074520aef774a083ad589
3
+ metadata.gz: a055862b32f99723985e08f5f89b5919d4e606189db5ad144757d44f3ac3ac71
4
+ data.tar.gz: f1fe3d727f9d676af14d69ce17eef0ffb3b1a6273693af9671e739fbfa6ef88a
5
5
  SHA512:
6
- metadata.gz: 1c4e2198c55d6379b0bb1f22577dd49d344c5a43bfec43cd48a46d5ef2b1025c1a4074814c324cde95f71d4864dd94b9b08c706be6b72adbf5c4c8287d0c376d
7
- data.tar.gz: bb9bac8b03c95e7b0b8985e71dbf4c1fed6272d8f79d69ac03a8a5319124fbe1e22f2036f31d1ba17d89cc4cdefa3d841e709d154b724b503ace00c428abd7bb
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, report_download_url)
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
- @report_download_url = report_download_url
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
- report = ('ClarkKent::ReportEmail' == report_class.name) ? reportable.report : reportable
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
- report.report_result_url.to_s
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: 'boardwalk')
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
- Sendgrid.send_message(mail)
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
- Sendgrid.send_message(mail)
58
+ mail.deliver_now
59
59
  end
60
60
 
61
61
  def report_filter_params
@@ -1,2 +1,7 @@
1
- Click this link to download your report:
2
- <a href="<%= @report_download_url %>"><%= @report.name %></a>
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 %>
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ClarkKent
2
- VERSION = "0.10.4"
2
+ VERSION = "0.11.0"
3
3
  end
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.10.4
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-01-24 00:00:00.000000000 Z
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails