diff --git a/README.md b/README.md
index 4ae9e422e..861f944bc 100644
--- a/README.md
+++ b/README.md
@@ -54,4 +54,4 @@ To create a tagged release use the [steps in the RDSS handbook](https://github.c
An early stages Entity-Relationship Diagram (ERD) is available in [this Google Doc](https://docs.google.com/drawings/d/1q2sfj8rrcNVgqQPK5uT_t79A9SYqncinh3HbnCSGMyQ/edit).
### Sample Data
-Sample data available here: https://docs.google.com/document/d/18ZkBldqWxIIR1UA6qMY87RnGFTKU9HG3EJzodzzFf2A/edit#heading=h.cj3zec9ihjhc
+Sample data available here: https://docs.google.com/document/d/18ZkBldqWxIIR1UA6qMY87RnGFTKU9HG3EJzodzzFf2A/edit
diff --git a/app/models/dataset.rb b/app/models/dataset.rb
index ff3dd6fa0..63cd35224 100644
--- a/app/models/dataset.rb
+++ b/app/models/dataset.rb
@@ -22,11 +22,15 @@ class Dataset < ApplicationRecord
end
after_save do |ds|
- if ds.ark.present?
- # Ensure that the ARK metadata is updated for the new URL
- if ark_object.target != ds.url
- ark_object.target = ds.url
- ark_object.save!
+ # We only want to update the ark url under certain conditions.
+ # Set this value in config/update_ark_url.yml
+ if Rails.configuration.update_ark_url
+ if ds.ark.present?
+ # Ensure that the ARK metadata is updated for the new URL
+ if ark_object.target != ds.url
+ ark_object.target = ds.url
+ ark_object.save!
+ end
end
end
end
diff --git a/app/models/s3_file.rb b/app/models/s3_file.rb
index a8490be21..30a150985 100644
--- a/app/models/s3_file.rb
+++ b/app/models/s3_file.rb
@@ -1,8 +1,10 @@
# frozen_string_literal: true
class S3File
- attr_accessor :filename
+ attr_accessor :filename, :last_modified, :size
- def initialize(filename:)
+ def initialize(filename:, last_modified:, size:)
@filename = filename
+ @last_modified = last_modified
+ @size = size
end
end
diff --git a/app/services/s3_query_service.rb b/app/services/s3_query_service.rb
index 328632349..073463e86 100644
--- a/app/services/s3_query_service.rb
+++ b/app/services/s3_query_service.rb
@@ -48,7 +48,7 @@ def data_profile
objects = []
resp = client.list_objects_v2({ bucket: bucket_name, max_keys: 1000, prefix: prefix })
resp.to_h[:contents].each do |object|
- s3_file = S3File.new(filename: object[:key])
+ s3_file = S3File.new(filename: object[:key], last_modified: object[:last_modified], size: object[:size])
objects << s3_file
end
objects
diff --git a/app/views/datasets/show.html.erb b/app/views/datasets/show.html.erb
index b1a65c58c..fba945afd 100644
--- a/app/views/datasets/show.html.erb
+++ b/app/views/datasets/show.html.erb
@@ -1,22 +1,63 @@
<%= @dataset.title %>
+
DOI: <%= link_to(@dataset.doi, @dataset.doi) %>
ARK: <%= link_to(@dataset.ark, @dataset.ark_url) %>
Created by: <%= @dataset.created_by_user.uid %>
Collection: <%= @dataset.collection_title %>
-
-
-
Files in S3
- <% if @files %>
- <% @files.each do |file| %>
- <%= file.filename %>
- <% end %>
- <% else %>
-
No files in S3
- <% end %>
-
+
+
+
+
+
+
+
+
+ <% if @files && @files.empty? %>
+
No files in S3
+ <% else %>
+
+
+
+ # |
+ Filename |
+ Last Modified |
+ Filesize |
+
+
+
+ <% @files&.each_with_index do |file, ix| %>
+
+
+ <%= ix + 1 %>
+ |
+
+
+
+ <%= truncate(file.filename, length: 80) %>
+
+ |
+
+ <%= file.last_modified %>
+ |
+
+ <%= number_to_human_size(file.size) %>
+ |
+
+ <% end %>
+
+
+
+ <% end %>
+
+
+
+
+
+
+
<%= link_to("Edit", edit_dataset_path(@dataset), class: "btn btn-primary") %>
diff --git a/config/initializers/load_update_ark_url.rb b/config/initializers/load_update_ark_url.rb
new file mode 100644
index 000000000..a3f662a1e
--- /dev/null
+++ b/config/initializers/load_update_ark_url.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+module PdcDescribe
+ class Application < Rails::Application
+ config.update_ark_url = config_for(:update_ark_url)
+ end
+end
diff --git a/config/update_ark_url.yml b/config/update_ark_url.yml
new file mode 100644
index 000000000..28ce6764a
--- /dev/null
+++ b/config/update_ark_url.yml
@@ -0,0 +1,9 @@
+---
+production:
+ false
+staging:
+ false
+development:
+ false
+test:
+ false
diff --git a/spec/factories/dataset.rb b/spec/factories/dataset.rb
index 3a1a3163d..3c56b2415 100644
--- a/spec/factories/dataset.rb
+++ b/spec/factories/dataset.rb
@@ -4,7 +4,7 @@
factory :dataset do
factory :shakespeare_and_company_dataset do
doi { "https://doi.org/10.34770/pe9w-x904" }
- ark { "http://arks.princeton.edu/ark:/88435/dsp01zc77st047" }
+ ark { "ark:/88435/dsp01zc77st047" }
work { FactoryBot.create(:shakespeare_and_company_work) }
end
end
diff --git a/spec/models/dataset_spec.rb b/spec/models/dataset_spec.rb
index dca947220..207c4e9ff 100644
--- a/spec/models/dataset_spec.rb
+++ b/spec/models/dataset_spec.rb
@@ -62,6 +62,12 @@
subject(:data_set) { described_class.create_skeleton("test title", user.id, collection.id) }
context "and when the ARK is valid" do
+ around do |example|
+ Rails.configuration.update_ark_url = true
+ example.run
+ Rails.configuration.update_ark_url = false
+ end
+
before do
# stub_request(:get, "https://ezid.cdlib.org/id/#{ezid}").to_return(status: 200, body: response_body)
end
diff --git a/spec/models/s3_file_spec.rb b/spec/models/s3_file_spec.rb
index 81062d09c..55cd09453 100644
--- a/spec/models/s3_file_spec.rb
+++ b/spec/models/s3_file_spec.rb
@@ -2,10 +2,14 @@
require "rails_helper"
RSpec.describe S3File, type: :model do
- let(:subject) { described_class.new(filename: filename) }
- let(:filename) { "research_data.csv" }
+ let(:subject) { described_class.new(filename: filename, last_modified: last_modified, size: size) }
+ let(:filename) { "10-34770/pe9w-x904/SCoData_combined_v1_2020-07_README.txt" }
+ let(:last_modified) { Time.parse("2022-04-21T18:29:40.000Z") }
+ let(:size) { 10_759 }
- it "can take a filename as an initial argument" do
+ it "can take S3 file data at creation time" do
expect(subject.filename).to eq filename
+ expect(subject.last_modified).to eq last_modified
+ expect(subject.size).to eq size
end
end
diff --git a/spec/services/s3_query_service_spec.rb b/spec/services/s3_query_service_spec.rb
index 0b1564799..945f39908 100644
--- a/spec/services/s3_query_service_spec.rb
+++ b/spec/services/s3_query_service_spec.rb
@@ -48,5 +48,7 @@
expect(data_profile.count).to eq 2
expect(data_profile.first).to be_instance_of(S3File)
expect(data_profile.first.filename).to match(/README/)
+ expect(data_profile.first.last_modified).to eq Time.parse("2022-04-21T18:29:40.000Z")
+ expect(data_profile.first.size).to eq 10_759
end
end
diff --git a/spec/system/view_data_in_s3_spec.rb b/spec/system/view_data_in_s3_spec.rb
index 78d955443..3231a3322 100644
--- a/spec/system/view_data_in_s3_spec.rb
+++ b/spec/system/view_data_in_s3_spec.rb
@@ -36,8 +36,20 @@
let(:user) { FactoryBot.create :user }
let(:dataset) { FactoryBot.create :shakespeare_and_company_dataset }
let(:s3_query_service_double) { instance_double(S3QueryService) }
- let(:file1) { S3File.new(filename: "SCoData_combined_v1_2020-07_README.txt") }
- let(:file2) { S3File.new(filename: "SCoData_combined_v1_2020-07_datapackage.json") }
+ let(:file1) do
+ S3File.new(
+ filename: "SCoData_combined_v1_2020-07_README.txt",
+ last_modified: Time.parse("2022-04-21T18:29:40.000Z"),
+ size: 10_759
+ )
+ end
+ let(:file2) do
+ S3File.new(
+ filename: "SCoData_combined_v1_2020-07_datapackage.json",
+ last_modified: Time.parse("2022-04-21T18:30:07.000Z"),
+ size: 12_739
+ )
+ end
let(:s3_data) { [file1, file2] }
before do
@@ -48,8 +60,14 @@
it "shows data from S3", js: true do
visit dataset_path(dataset)
expect(page).to have_content dataset.title
+
expect(page).to have_content file1.filename
+ expect(page).to have_content file1.last_modified
+ expect(page).to have_content "10.5 KB"
+
expect(page).to have_content file2.filename
+ expect(page).to have_content file2.last_modified
+ expect(page).to have_content "12.4 KB"
end
end
end