Skip to content

Commit

Permalink
Merge branch 'seek-1.14' into fairdomhub
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Feb 2, 2024
2 parents 02da519 + 3b45e1f commit 579b1cb
Show file tree
Hide file tree
Showing 10 changed files with 1,655 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem 'hpricot', '~>0.8.2'
gem 'libxml-ruby', '~>2.9.0', require: 'libxml'
gem 'uuid', '~>2.3'
gem 'RedCloth', '>=4.3.0'
gem 'simple-spreadsheet-extractor', '~> 0.18.0'
gem 'simple-spreadsheet-extractor', '0.18.1'
gem 'open4'
gem 'sample-template-generator', '~>0.7'
gem 'rmagick', '4.2.5'
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ GEM
citeproc-ruby (2.0.0)
citeproc (~> 1.0, >= 1.0.9)
csl (~> 2.0)
climate_control (0.2.0)
climate_control (1.2.0)
code_analyzer (0.5.5)
sexp_processor
coderay (1.1.3)
Expand Down Expand Up @@ -774,9 +774,9 @@ GEM
rubyntlm (0.6.3)
rubyzip (2.0.0)
rugged (1.1.0)
sample-template-generator (0.7.0)
sample-template-generator (0.7.1)
rdoc (~> 6.0)
terrapin (~> 0.6)
terrapin (~> 1.0)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
Expand Down Expand Up @@ -821,9 +821,9 @@ GEM
rdf-xsd (~> 3.2)
sparql (~> 3.2)
sxp (~> 1.2)
simple-spreadsheet-extractor (0.18.0)
simple-spreadsheet-extractor (0.18.1)
libxml-ruby (~> 2.9)
terrapin (~> 0.6)
terrapin (~> 1.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -875,8 +875,8 @@ GEM
teaspoon-mocha (2.3.3)
teaspoon (>= 1.0.0)
temple (0.8.2)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
terrapin (1.0.1)
climate_control
terser (1.1.8)
execjs (>= 0.3.0, < 3)
test-prof (1.0.7)
Expand Down Expand Up @@ -1073,7 +1073,7 @@ DEPENDENCIES
sass-rails (>= 6)
savon (= 1.1.0)
seedbank
simple-spreadsheet-extractor (~> 0.18.0)
simple-spreadsheet-extractor (= 0.18.1)
simplecov
sprockets-rails
sqlite3 (~> 1.4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<% end %>
</div>
<% unless resource.unreleased %>
<% unless resource.unreleased || resource.main_filename.blank? %>
<div class="col-sm-2 text-right list_item_actions">
<%
biomodel_download_link = resource.download_link
Expand Down
16 changes: 11 additions & 5 deletions lib/seek/biomodels_search/search_biomodels_adaptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ def perform_search(query)

json = JSON.parse(json)
json['models'].collect do |result|
BiomodelsSearchResult.new result['id']
begin
BiomodelsSearchResult.new result['id']
rescue NoMethodError=>exception
Seek::Errors::ExceptionForwarder.send_notification(exception, data: { error: 'error reading response from BioModels', item_id: result['id'], query: query })
nil
end
end.compact.reject do |biomodels_result|
biomodels_result.title.blank?
end
Expand Down Expand Up @@ -62,14 +67,15 @@ def populate
self.publication_title = json.dig('publication', 'title')
self.authors = (json.dig('publication', 'authors') || []).collect { |author| author['name'] }
self.published_date = Time.at(json['firstPublished'] / 1000)
latest_version = json['history']['revisions'].sort { |rev| rev['version'] }.first
self.last_modification_date = Time.at(latest_version['submitted'] / 1000)
self.main_filename = json['files']['main'].first['name']
latest_version = (json.dig('history','revisions') || []).sort { |rev| rev['version'] }&.first
if latest_version&.fetch('submitted')
self.last_modification_date = Time.at(latest_version['submitted'] / 1000)
end
self.main_filename = (json.dig('files','main') || []).first&.fetch('name')
self.unreleased = false
else
self.unreleased = true
end

end
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/factories/content_blobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@
content_type { 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }
data { File.new("#{Rails.root}/test/fixtures/files/blank-master-template.xlsx", 'rb').read }
end

factory(:spreadsheet_with_error_logs_content_blob, parent: :content_blob) do
original_filename { 'spreadsheet-with-poi-error-logs.xlsx' }
content_type { 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }
data { File.new("#{Rails.root}/test/fixtures/files/spreadsheet-with-poi-error-logs.xlsx", 'rb').read }
end

factory(:blank_content_blob, class: ContentBlob) do
url { nil }
Expand Down
4 changes: 4 additions & 0 deletions test/factories/data_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
factory(:small_test_spreadsheet_datafile, parent: :data_file) do
association :content_blob, factory: :small_test_spreadsheet_content_blob
end

factory(:spreadsheet_with_error_logs_datafile, parent: :data_file) do
association :content_blob, factory: :spreadsheet_with_error_logs_content_blob
end

factory(:strain_sample_data_file, parent: :data_file) do
association :content_blob, factory: :strain_sample_data_content_blob
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions test/functional/data_files_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,13 @@ def test_show_item_attributed_to_jerm_file
assert_response :success
end

test 'explore spreadsheet with error logs' do
data = FactoryBot.create :spreadsheet_with_error_logs_datafile, policy: FactoryBot.create(:public_policy)
get :explore, params: { id: data }
assert_response :success
assert_select 'div#spreadsheet_1 table.sheet td#cell_B4',text:'ProjectDescription'
end

test 'explore earlier version' do

df = FactoryBot.create(:small_test_spreadsheet_datafile)
Expand Down
9 changes: 9 additions & 0 deletions test/unit/search_biomodels_adaptor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class SearchBiomodelsAdaptorTest < ActiveSupport::TestCase
assert_equal DateTime.parse('2012-12-14 14:24:40 +0000'), result.last_modification_date
assert_equal 'search/partials/test_partial', result.partial_path
assert_equal 'EBI Biomodels', result.tab
assert_equal 'BIOMD0000000429_url.xml', result.main_filename
end

end
Expand All @@ -64,5 +65,13 @@ class SearchBiomodelsAdaptorTest < ActiveSupport::TestCase
end
end

test 'search does not files' do
VCR.use_cassette('biomodels/search-2024') do
adaptor = Seek::BiomodelsSearch::SearchBiomodelsAdaptor.new('partial_path' => 'search/partials/test_partial')
results = adaptor.search('2024')
assert_equal 25, results.count
end
end


end
1,608 changes: 1,608 additions & 0 deletions test/vcr_cassettes/biomodels/search-2024.yml

Large diffs are not rendered by default.

0 comments on commit 579b1cb

Please sign in to comment.