Class: Lighthouse::DocumentUpload
- Inherits:
-
Object
- Object
- Lighthouse::DocumentUpload
show all
- Extended by:
- SentryLogging
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/lighthouse/document_upload.rb
Constant Summary
collapse
- FILENAME_EXTENSION_MATCHER =
/\.\w*$/
- OBFUSCATED_CHARACTER_MATCHER =
/[a-zA-Z\d]/
- DD_ZSF_TAGS =
['service:claim-status', 'function: evidence upload to Lighthouse'].freeze
- NOTIFY_SETTINGS =
Settings.vanotify.services.benefits_management_tools
- MAILER_TEMPLATE_ID =
NOTIFY_SETTINGS.template_id.evidence_submission_failure_email
Class Method Summary
collapse
Instance Method Summary
collapse
log_exception_to_sentry, log_message_to_sentry, non_nil_hash?, normalize_level, rails_logger, set_sentry_metadata
Class Method Details
70
71
72
73
74
75
76
|
# File 'app/sidekiq/lighthouse/document_upload.rb', line 70
def self.format_issue_instant_for_mailers(issue_instant)
timestamp = Time.at(issue_instant).in_time_zone('America/New_York')
timestamp.strftime('%B %-d, %Y %-l:%M %P %Z').sub(/([ap])m/, '\1.m.')
end
|
.notify_client ⇒ Object
78
79
80
|
# File 'app/sidekiq/lighthouse/document_upload.rb', line 78
def self.notify_client
VaNotify::Service.new(NOTIFY_SETTINGS.api_key)
end
|
.obscured_filename(original_filename) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/sidekiq/lighthouse/document_upload.rb', line 55
def self.obscured_filename(original_filename)
extension = original_filename[FILENAME_EXTENSION_MATCHER]
filename_without_extension = original_filename.gsub(FILENAME_EXTENSION_MATCHER, '')
if filename_without_extension.length > 5
obfuscated_portion = filename_without_extension[3..-3].gsub(OBFUSCATED_CHARACTER_MATCHER, 'X')
filename_without_extension[0..2] + obfuscated_portion + filename_without_extension[-2..] + extension
else
original_filename
end
end
|
Instance Method Details
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'app/sidekiq/lighthouse/document_upload.rb', line 82
def perform(user_icn, document_hash)
client = BenefitsDocuments::WorkerService.new
document, file_body, uploader = nil
Datadog::Tracing.trace('Config/Initialize Upload Document') do
Sentry.set_tags(source: 'documents-upload')
document = LighthouseDocument.new document_hash
raise Common::Exceptions::ValidationErrors, document_data unless document.valid?
uploader = LighthouseDocumentUploader.new(user_icn, document.uploader_ids)
uploader.retrieve_from_store!(document.file_name)
end
Datadog::Tracing.trace('Sidekiq read_for_upload') do
file_body = uploader.read_for_upload
end
Datadog::Tracing.trace('Sidekiq Upload Document') do |span|
span.set_tag('Document File Size', file_body.size)
client.upload_document(file_body, document)
end
Datadog::Tracing.trace('Remove Upload Document') do
uploader.remove!
end
end
|