Add a UUID to the end of export filenames

This commit is contained in:
Eric 2020-05-08 16:47:39 -05:00
parent 5b0110e1ef
commit 4625aef641
8 changed files with 15 additions and 8 deletions

View file

@ -53,7 +53,7 @@ module ExportPayments
end
file_date = Time.now.getutc.strftime('%m-%d-%Y--%H-%M-%S')
filename = "tmp/csv-exports/payments-#{file_date}.csv"
filename = "tmp/csv-exports/payments-#{file_date}-#{SecureRandom.uuid}.csv"
ChunkedUploader.upload(QueryPayments.for_export_enumerable(npo_id, params, 30_000).map(&:to_csv)) do |io|
CHUNKED_UPLOAD_SERVICE.upload(filename, io, content_type: 'text/csv', content_disposition: 'attachment')

View file

@ -53,7 +53,7 @@ module ExportRecurringDonations
end
file_date = Time.now.getutc.strftime('%m-%d-%Y--%H-%M-%S')
filename = "tmp/csv-exports/recurring_donations-#{file_date}.csv"
filename = "tmp/csv-exports/recurring_donations-#{file_date}-#{SecureRandom.uuid}.csv"
ChunkedUploader.upload(QueryRecurringDonations.for_export_enumerable(npo_id, params, 30_000).map(&:to_csv)) do |io|
CHUNKED_UPLOAD_SERVICE.upload(filename, io, content_type: 'text/csv', content_disposition: 'attachment')

View file

@ -52,7 +52,7 @@ module ExportSupporterNotes
end
file_date = Time.now.getutc.strftime('%m-%d-%Y--%H-%M-%S')
filename = "tmp/csv-exports/supporters-notes-#{file_date}.csv"
filename = "tmp/csv-exports/supporters-notes-#{file_date}-#{SecureRandom.uuid}.csv"
ChunkedUploader.upload(QuerySupporters.supporter_note_export_enumerable(npo_id, params, 30_000).map(&:to_csv)) do |io|
CHUNKED_UPLOAD_SERVICE.upload(filename, io, content_type: 'text/csv', content_disposition: 'attachment')

View file

@ -50,7 +50,7 @@ module ExportSupporters
end
file_date = Time.now.getutc.strftime('%m-%d-%Y--%H-%M-%S')
filename = "tmp/csv-exports/supporters-#{file_date}.csv"
filename = "tmp/csv-exports/supporters-#{file_date}-#{SecureRandom.uuid}.csv"
ChunkedUploader.upload(QuerySupporters.for_export_enumerable(npo_id, params, 30_000).map(&:to_csv)) do |io|
CHUNKED_UPLOAD_SERVICE.upload(filename, io, content_type: 'text/csv', content_disposition: 'attachment')

View file

@ -21,6 +21,8 @@ describe ExportPayments do
force_create(:payment, gross_amount: 2000, fee_total: 22, net_amount: 1978, supporter: supporters[1], nonprofit: nonprofit)]
end
let(:export_url_regex) { /http:\/\/fake\.url\/tmp\/csv-exports\/payments-04-06-2020--01-02-03-#{UUID::Regex}\.csv/}
before(:each) do
payments
end
@ -181,7 +183,7 @@ describe ExportPayments do
expect(ExportPaymentsCompletedJob).to have_been_enqueued.with(@export)
@export.reload
expect(@export.url).to eq 'http://fake.url/tmp/csv-exports/payments-04-06-2020--01-02-03.csv'
expect(@export.url).to match export_url_regex
expect(@export.status).to eq 'completed'
expect(@export.exception).to be_nil
expect(@export.ended).to eq Time.now

View file

@ -19,6 +19,8 @@ describe ExportRecurringDonations do
CHUNKED_UPLOAD_SERVICE.clear
end
let(:export_url_regex) { /http:\/\/fake\.url\/tmp\/csv-exports\/recurring_donations-04-06-2020--01-02-03-#{UUID::Regex}\.csv/}
context '.initiate_export' do
context 'param verification' do
it 'performs initial verification' do
@ -175,7 +177,7 @@ describe ExportRecurringDonations do
expect(ExportRecurringDonationsCompletedJob).to have_been_enqueued.with(@export)
@export.reload
expect(@export.url).to eq 'http://fake.url/tmp/csv-exports/recurring_donations-04-06-2020--01-02-03.csv'
expect(@export.url).to match export_url_regex
expect(@export.status).to eq 'completed'
expect(@export.exception).to be_nil
expect(@export.ended).to eq Time.now

View file

@ -46,6 +46,8 @@ describe ExportSupporterNotes do
force_create(:supporter_note, supporter: supporter2, created_at: DateTime.new(2020, 4, 5), content: note_content_3)
end
let(:export_url_regex) { /http:\/\/fake\.url\/tmp\/csv-exports\/supporters-notes-04-06-2020--01-02-03-#{UUID::Regex}\.csv/}
context '.initiate_export' do
context 'param verification' do
it 'performs initial verification' do
@ -206,7 +208,7 @@ describe ExportSupporterNotes do
@export.reload
expect(@export.url).to eq 'http://fake.url/tmp/csv-exports/supporters-notes-04-06-2020--01-02-03.csv'
expect(@export.url).to match export_url_regex
expect(@export.status).to eq 'completed'
expect(@export.exception).to be_nil
expect(@export.ended).to eq Time.now

View file

@ -13,6 +13,7 @@ describe ExportSupporters do
@supporters = 2.times { force_create(:supporter, nonprofit: @nonprofit) }
end
let(:export_header) { 'Last Name,First Name,Full Name,Organization,Email,Phone,Address,City,State,Postal Code,Country,Anonymous?,Supporter Id,Total Contributed,Id,Last Payment Received,Notes,Tags'.split(',') }
let(:export_url_regex) { /http:\/\/fake\.url\/tmp\/csv-exports\/supporters-04-06-2020--01-02-03-#{UUID::Regex}\.csv/}
context '.initiate_export' do
context 'param verification' do
@ -172,7 +173,7 @@ describe ExportSupporters do
@export.reload
expect(@export.url).to eq 'http://fake.url/tmp/csv-exports/supporters-04-06-2020--01-02-03.csv'
expect(@export.url).to match export_url_regex
expect(@export.status).to eq 'completed'
expect(@export.exception).to be_nil
expect(@export.ended).to eq Time.now