zizia 4.4.1.alpha.01 → 4.5.1.alpha.01

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: 9629a59be90ca2d1b2d56ea38c6a1de8bad912bd7c4843e21a8625fceb1ef581
4
- data.tar.gz: 35aa1ba6679804b0ceaab32696ce3a2a4ff47076ccced0a585493e18933d09fd
3
+ metadata.gz: be8096fc629accb26c9372a1d504a26e27ea0f8bd45b91ef19d35c45b747e566
4
+ data.tar.gz: b16397d6834829c155ba18f3f66850bb4f67a382579f7f7e34d2c1890a755e2d
5
5
  SHA512:
6
- metadata.gz: 723108c90866bf5d8d1db2380731f4448dc46c94eb670b708549f2fe5bc9c0a8032bc63f1e1ca9f0c16bf6283cd3eda970331986ab18cef7157d5f64b221205d
7
- data.tar.gz: ef217c2d1820075ecaf8514c9d78b90ae4a76e0cf3f68426278a6f9b84383e7f39d938bd3d300f522d363c7ec1ad0aa02d917a1fa5818c218bb66601c96cc8d5
6
+ metadata.gz: 8ddd55ffcb647acc0c356decbcf1de863c8110e40e54454a2d7a34325c8700a92d0cca75ea638589fdff43352895939d9a71385e9fe49de8c2b0ad8d275b81aa
7
+ data.tar.gz: 9b6124b66ffe83170c5413748245981510369f4ac7b75eab95a3e7612068a434d0b2273c589be63e3ee4c1f87e3993e8a368f707ca143e0b8c04b7e023fafd92
@@ -25,7 +25,7 @@ class ModularImporter
25
25
  csv_import_detail.batch_id = @csv_import.id
26
26
  csv_import_detail.deduplication_field = DEDUPLICATION_FIELD
27
27
  csv_import_detail.update_actor_stack = @csv_import.update_actor_stack
28
- csv_import_detail.save!
28
+ csv_import_detail.save
29
29
 
30
30
  attrs = {
31
31
  csv_import_detail: csv_import_detail
@@ -34,18 +34,21 @@ class ModularImporter
34
34
  Rails.logger.info "[zizia] event: start_import, batch_id: #{@csv_import.id}, collection_id: #{@collection_id}, user: #{@user_email}"
35
35
  importer = Zizia::Importer.new(parser: Zizia::CsvParser.new(file: file), record_importer: Zizia::HyraxRecordImporter.new(attributes: attrs))
36
36
 
37
- importer.records.each do |record|
37
+ importer.records.each_with_index do |record, index|
38
38
  pre_ingest_work = Zizia::PreIngestWork.new(csv_import_detail_id: csv_import_detail.id)
39
- @row += 1
40
-
41
- pre_ingest_file = Zizia::PreIngestFile.new(row_number: @row,
42
- pre_ingest_work: pre_ingest_work,
43
- filename: record.mapper.files.first,
44
- size: File.join(ENV['IMPORT_PATH'], record.mapper.files.first).size)
45
- pre_ingest_work.save!
46
- pre_ingest_file.save!
39
+
40
+ record.mapper.files.each do |child_file|
41
+ full_path = Dir.glob("#{ENV['IMPORT_PATH']}/**/#{child_file}").first
42
+ pre_ingest_file = Zizia::PreIngestFile.new(row_number: index + 1,
43
+ pre_ingest_work: pre_ingest_work,
44
+ filename: child_file,
45
+ size: File.size(full_path))
46
+ pre_ingest_file.save
47
+ end
48
+ pre_ingest_work.save
47
49
  end
48
- csv_import_detail.save!
50
+
51
+ csv_import_detail.save
49
52
  importer.import
50
53
  file.close
51
54
  end
@@ -4,7 +4,8 @@
4
4
  <th>ID</th>
5
5
  <th>Associated User</th>
6
6
  <th>CSV File</th>
7
- <th>Total Size in Bytes</th>
7
+ <th>Number of Works</th>
8
+ <th>Total Size</th>
8
9
  </tr>
9
10
  <% @csv_import_details.each do |csv_import_detail| %>
10
11
  <tr>
@@ -18,7 +19,10 @@
18
19
  <%= csv_import_detail.csv_import.manifest %>
19
20
  </td>
20
21
  <td>
21
- <%= csv_import_detail.total_size %>
22
+ <%= csv_import_detail.pre_ingest_works.count %>
23
+ </td>
24
+ <td>
25
+ <%= number_to_human_size(csv_import_detail.total_size) %>
22
26
  </td>
23
27
  </tr>
24
28
  <% end %>
@@ -4,7 +4,7 @@
4
4
  <li>Import created by: <%= User.find(@csv_import_detail.csv_import.user_id) %>
5
5
  </li>
6
6
  <li>CSV File: <%= @csv_import_detail.csv_import.manifest %></li>
7
- <li>Total Size in Bytes: <%= @csv_import_detail.total_size %></li>
7
+ <li>Total Size: <%= number_to_human_size(@csv_import_detail.total_size) %></li>
8
8
  </ul>
9
9
 
10
10
  <h3>Files</h3>
@@ -21,10 +21,9 @@
21
21
  <%= pre_ingest_file.filename %>
22
22
  </td>
23
23
  <td>
24
- <%= pre_ingest_file.size %>
24
+ <%= number_to_human_size(pre_ingest_file.size) %>
25
25
  </td>
26
26
  <td>
27
- Row number:
28
27
  <%= pre_ingest_file.row_number %>
29
28
  </td>
30
29
  </tr>
data/lib/zizia/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zizia
4
- VERSION = '4.4.1.alpha.01'
4
+ VERSION = '4.5.1.alpha.01'
5
5
  end
@@ -13,6 +13,6 @@ RSpec.describe 'viewing the csv import detail page' do
13
13
  visit ('/csv_import_details/index')
14
14
  expect(page).to have_content('CSV Imports ID')
15
15
  click_on '1'
16
- expect(page).to have_content('Total Size in Bytes')
16
+ expect(page).to have_content('Total Size')
17
17
  end
18
18
  end
@@ -241,9 +241,10 @@ RSpec.describe 'Importing records from a CSV file', :perform_jobs, :clean, type:
241
241
 
242
242
  # Viewing additional details after an import
243
243
  visit "/csv_import_details/index"
244
- expect(page).to have_content('Total Size in Bytes')
244
+ expect(page).to have_content('Total Size')
245
245
  find(:xpath, '//*[@id="content-wrapper"]/table/tbody/tr[2]/td[1]/a').click
246
246
  expect(page).to have_content('dog.jpg')
247
+ expect(page).to have_content('5.74 MB')
247
248
  end
248
249
  end
249
250
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zizia
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1.alpha.01
4
+ version: 4.5.1.alpha.01
5
5
  platform: ruby
6
6
  authors:
7
7
  - Data Curation Experts