Skip to content

Commit

Permalink
Merge branch 'release/0.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Dec 4, 2024
2 parents 2424e4b + a07f4e8 commit 893402a
Show file tree
Hide file tree
Showing 40 changed files with 111 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
env:
POSTGRES_HOST: 127.0.0.1
POSTGRES_PORT: 5555
POSTGRES_DB: geoblacklight_test
POSTGRES_DB: geoblacklight_admin_development
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ The gem is available as open source under the terms of the [Apache 2.0 License](
* ~~Debug Rails 7.2 support (remove devise_invitable, see [#915](https://github.com/scambra/devise_invitable/issues/915))~~
* ~~Separate dct_references_s support into a separate model~~
* ~~Import/Export dct_references_s outside of the main document model~~
* Migrate our GBL API controllers to just RSolr-based models
* DRY up Gem dependencies and Engine routing
* Data Dictionary: Add support for `document_data_dictionary`
* Gazetteer: Add GeoNames support
* Gazetteer: Add Who's On First support
* Gazetteer: Add Ollama support
* Gazetteer: Add BTAA spatial file support
* Migrate our GBL API controllers to just RSolr-based models
* DRY up Gem dependencies and Engine routing
* Remove any remaining GEOMG references
2 changes: 2 additions & 0 deletions app/models/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def to_aardvark_reference
if dct_references_uri_key.present?
reference_type = ReferenceType.find_by_name(dct_references_uri_key)
hash[reference_type.reference_uri.to_s] = if reference_type.reference_uri.to_s == "http://schema.org/downloadUrl"
logger.debug("Asset#to_aardvark_reference > downloadUrl: #{full_file_url} > #{label.present? ? label : file.metadata["filename"]}")

{
"url" => full_file_url,
"label" => label.present? ? label : file.metadata["filename"]
Expand Down
42 changes: 21 additions & 21 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,35 +122,35 @@ def a_downloadable_resource?
# - Use distributable assets
# @TODO: Remove BEFORE path once we've migrated to DocumentDistributions
def distributions
distributions = ActiveSupport::HashWithIndifferentAccess.new
distributions = {}

# AFTER - Add DocumentDistributions to distributions
if ENV["GBL_ADMIN_REFERENCES_MIGRATED"] == "true"
distributions = document_distributions.to_aardvark_distributions
end

# BEFORE - Prep value arrays
# @TODO: Remove this once we've migrated to DocumentDistributions
send(GeoblacklightAdmin::Schema.instance.solr_fields[:reference]).each do |ref|
if ref.category.present?
distributions[Document::Reference::REFERENCE_VALUES[ref.category.to_sym][:uri]] = []
else
# BEFORE - Prep value arrays
# @TODO: Remove this once we've migrated to DocumentDistributions
send(GeoblacklightAdmin::Schema.instance.solr_fields[:reference]).each do |ref|
if ref.category.present?
distributions[Document::Reference::REFERENCE_VALUES[ref.category.to_sym][:uri]] = []
end
end
end

# BEFORE - Seed value arrays
# @TODO: Remove this once we've migrated to DocumentDistributions
send(GeoblacklightAdmin::Schema.instance.solr_fields[:reference]).each do |ref|
if ref.category.present?
distributions[Document::Reference::REFERENCE_VALUES[ref.category.to_sym][:uri]] << ref.value
# BEFORE - Seed value arrays
# @TODO: Remove this once we've migrated to DocumentDistributions
send(GeoblacklightAdmin::Schema.instance.solr_fields[:reference]).each do |ref|
if ref.category.present?
distributions[Document::Reference::REFERENCE_VALUES[ref.category.to_sym][:uri]] << ref.value
end
end
end
logger.debug("\n\nDocument#distributions > seeded: #{distributions}")
logger.debug("\n\nDocument#distributions > seeded: #{distributions}")

# BEFORE - Apply Multiple Downloads
# @TODO: Remove this once we've migrated to DocumentDistributions
if ENV["GBL_ADMIN_REFERENCES_MIGRATED"] == "false"
distributions = apply_downloads(distributions)
logger.debug("Document#distributions > downloads: #{distributions}")
# BEFORE - Apply Multiple Downloads
# @TODO: Remove this once we've migrated to DocumentDistributions
if ENV["GBL_ADMIN_REFERENCES_MIGRATED"] == "false"
distributions = apply_downloads(distributions)
logger.debug("Document#distributions > downloads: #{distributions}")
end
end

# BEFORE & AFTER - Apply Distributable Assets
Expand Down
2 changes: 1 addition & 1 deletion app/models/document_distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DocumentDistribution < ApplicationRecord
merged["http://schema.org/downloadUrl"] ||= []
merged["http://schema.org/downloadUrl"] << {
"url" => dist.values.first,
"label" => dist[:label]
"label" => dist[:label].present? ? dist[:label] : dist.values.first
}
else
merged[dist.keys.first] = dist.values.first
Expand Down
1 change: 0 additions & 1 deletion app/models/geoblacklight_admin.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true

module GeoblacklightAdmin
include GeoblacklightAdmin::IsoLanguageCodes
end
2 changes: 0 additions & 2 deletions app/views/admin/advanced_search/facets.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.data do
json.array! @presenter.documents do |document|
document_url = polymorphic_url(url_for_document(document))
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/advanced_search/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.links do
json.self url_for(search_state.to_h.merge(only_path: false))
json.prev url_for(search_state.to_h.merge(only_path: false, page: @response.prev_page.to_s)) if @response.prev_page
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/api/_field.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.set!(field_name) do
json.id "#{document_url}##{field_name}"
json.type "document_value"
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/api/fetch.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.links do
json.self url_for(search_state.to_h.merge(only_path: false))
json.prev url_for(search_state.to_h.merge(only_path: false, page: @response.prev_page.to_s)) if @response.prev_page
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/api/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.links do
json.self url_for(search_state.to_h.merge(only_path: false))
json.prev url_for(search_state.to_h.merge(only_path: false, page: @response.prev_page.to_s)) if @response.prev_page
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/document_distributions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ document.addEventListener('DOMContentLoaded', function() {
const labelInput = document.getElementById('label-input');

function toggleLabelInput() {
if (distributionSelect.options[distributionSelect.selectedIndex].text === 'Download file') {
if (distributionSelect.options[distributionSelect.selectedIndex].text === 'Download') {
labelInput.disabled = false;
} else {
labelInput.disabled = true;
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/document_distributions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
<% if params[:document_id] %>
<h2 class='h3'>
<%= link_to(@document.title, admin_document_path(@document)) %>
&middot;
<%= @document_distributions.count %> distributions
</h2>
<% else %>
<h2 class='h3'>Distributions</h2>
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/documents/_form_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<% end %>
<%= link_to admin_document_document_distributions_url(@document), class: "ml-2" do %>
Distributions
<span class="badge badge-light"><%= @document.distributions.size %></span>
<% end %>
<% end %>
</nav>
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/_json_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# See GBL Aardvark Schema
# https://docs.google.com/spreadsheets/d/1QQjUzRe8YdPGKK4h0GYoNPTow2zZ1f0KFA0zzZyHAsk/edit?ts=602d52f2#gid=252925024

Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/_json_btaa_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# Required
json.set! :gbl_mdVersion_s, "BTAA Aardvark"

Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/_json_file.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# Required
json.set! :gbl_mdVersion_s, "BTAA Aardvark"

Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/_json_gbl_v1.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# See OpenGeoMetadata Legacy Versions
# https://opengeometadata.org/docs/gbl-1.0

Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/fetch.json_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/fetch.json_btaa_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/fetch.json_file.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/fetch.json_gbl_v1.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/index.json_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.load_all.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/index.json_btaa_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.load_all.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/index.json_file.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.load_all.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/index.json_gbl_v1.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

json.ignore_nil!

json.array! @documents.load_all.map do |document|
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/documents/show.json_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# frozen_string_literal: true

json.partial! "json_aardvark", document: @document
2 changes: 0 additions & 2 deletions app/views/admin/documents/show.json_btaa_aardvark.jbuilder
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# frozen_string_literal: true

json.partial! "json_btaa_aardvark", document: @document
2 changes: 0 additions & 2 deletions app/views/admin/documents/show.json_gbl_v1.jbuilder
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# frozen_string_literal: true

json.partial! "json_gbl_v1", document: @document
4 changes: 2 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ bundle install
### Create Database
```bash
psql postgres
DROP DATABASE geoblacklight_development;
CREATE DATABASE geoblacklight_development;
DROP DATABASE geoblacklight_admin_development;
CREATE DATABASE geoblacklight_admin_development;
```

### Run Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SOLR_URL=http://127.0.0.1:8983/solr/blacklight-core

# PostgreSQL
POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_PORT=5555
POSTGRES_DB=geoblacklight_admin_development
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
Expand All @@ -28,5 +28,5 @@ BLACKLIGHT_JSON_IDS=/admin/ids.json
GBL_ADMIN_REFERENCES_MIGRATED=true

# Blazer
BLAZER_UPLOADS_URL=postgresql://127.0.0.1:5432/geoblacklight_development
BLAZER_UPLOADS_URL=postgresql://127.0.0.1:5555/geoblacklight_admin_development
MAPBOX_ACCESS_TOKEN=your-key-here
2 changes: 1 addition & 1 deletion lib/geoblacklight_admin/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module GeoblacklightAdmin
VERSION = "0.6.0"
VERSION = "0.6.1"
end
2 changes: 1 addition & 1 deletion template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# 2. Run these lines below to stand up a new GBL + GBL Admin instance:
#
# $> rails _7.2.2_ new gbl_admin -m https://raw.githubusercontent.com/geobtaa/geoblacklight_admin/feature/develop/template.rb
# $> rails _7.2.2_ new gbl_admin -m https://raw.githubusercontent.com/geobtaa/geoblacklight_admin/develop/template.rb
# $> cd gbl_admin
# $> bundle exec rake geoblacklight:server
#
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/document_distributions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class DocumentReferencesControllerTest < ActionDispatch::IntegrationTest
setup do
@document = documents(:ls)
@document_distribution = document_distributions(:one)
@document_distribution = document_distributions(:ag_1)
@file = fixture_file_upload("import_distributions.csv", "text/csv")

get "/users/sign_in"
Expand Down
23 changes: 17 additions & 6 deletions test/fixtures/document_distributions.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
ag_1:
friendlier_id: 35c8a641589c4e13b7aa11e37f3f00a1_0
reference_type_id: 1
url: http://foo.com
label: Foo
reference_type_id: 8
url: https://open-iowa.opendata.arcgis.com/datasets/35c8a641589c4e13b7aa11e37f3f00a1_0
label:
position: 1

ag_2:
friendlier_id: 35c8a641589c4e13b7aa11e37f3f00a1_0
reference_type_id: 8
url: https://open-iowa.opendata.arcgis.com/datasets/35c8a641589c4e13b7aa11e37f3f00a1_0.zip
label:
position: 2
ag_3:
friendlier_id: 35c8a641589c4e13b7aa11e37f3f00a1_0
reference_type_id: 3
url: https://services2.arcgis.com/KhKjlwEBlPJd6v51/arcgis/rest/services/AgDistricts/FeatureServer/0
label: Agricultural Districts
position: 3
2 changes: 1 addition & 1 deletion test/fixtures/documents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ag:
type: Document
position:
json_attributes:
{"dcat_bbox": "-96.6391,40.3754,-90.1401,43.5012", "locn_geometry": "POLYGON((-80 25, -65 18, -64 33, -80 25))", "b1g_code_s": "03a-04", "dct_title_s": "Agricultural Districts: Iowa", "dct_format_s": "Shapefile", "dct_accessRights_s": "Public", "gbl_resourceClass_sm": ["Datasets"], "b1g_image_ss": null, "b1g_status_s": "Active", "dct_issued_s": "2015-09-03", "geomg_id_s": "35c8a641589c4e13b7aa11e37f3f00a1_0", "gbl_suppressed_b": false, "dct_creator_sm": ["Legislative Services Agency"], "dct_subject_sm": ["Boundaries"], "dcat_keyword_sm": ["iowa", "judicial", "districts", "boundaries"], "dct_language_sm": ["eng"], "dct_spatial_sm": ["Iowa"], "dcat_centroid": "41.9383,-93.3896", "b1g_geonames_sm": [], "dct_identifier_sm": ["35c8a641589c4e13b7aa11e37f3f00a1_0"], "dct_publisher_sm": ["State of Iowa"], "pcdm_memberOf_sm": ["03a-04"], "dct_isPartOf_sm": ["03a-04"], "dcat_theme_sm": ["Theme"], "dct_temporal_sm": ["2015"], "dct_description_sm": ["Iowa Agricultural Districts"], "schema_provider_s": "Iowa", "dct_references_s": [{"value": "https://open-iowa.opendata.arcgis.com/datasets/35c8a641589c4e13b7aa11e37f3f00a1_0", "category": "documentation_external"}, {"value": "https://open-iowa.opendata.arcgis.com/datasets/35c8a641589c4e13b7aa11e37f3f00a1_0.zip", "category": "download"}, {"value": "https://services2.arcgis.com/KhKjlwEBlPJd6v51/arcgis/rest/services/AgDistricts/FeatureServer/0", "category": "arcgis_feature_layer"}], "gbl_resourceType_sm": "Vector", "gbl_georeferenced_b": false, "b1g_child_record_b": false, "dct_rights_sm": [""], "b1g_dct_accrualMethod_s": "ArcGIS Hub", "gbl_dateRange_drsim": ["2015-2015"], "b1g_dateAccessioned_sm": ["2020-04-24"], "gbl_mdVersion_s": "Aardvark", "dct_alternative_sm": ["Ag Districts"], "b1g_dct_accrualPeriodicity_s": null}
{"dcat_bbox": "-96.6391,40.3754,-90.1401,43.5012", "locn_geometry": "POLYGON((-80 25, -65 18, -64 33, -80 25))", "b1g_code_s": "03a-04", "dct_title_s": "Agricultural Districts: Iowa", "dct_format_s": "Shapefile", "dct_accessRights_s": "Public", "gbl_resourceClass_sm": ["Datasets"], "b1g_image_ss": null, "b1g_status_s": "Active", "dct_issued_s": "2015-09-03", "geomg_id_s": "35c8a641589c4e13b7aa11e37f3f00a1_0", "gbl_suppressed_b": false, "dct_creator_sm": ["Legislative Services Agency"], "dct_subject_sm": ["Boundaries"], "dcat_keyword_sm": ["iowa", "judicial", "districts", "boundaries"], "dct_language_sm": ["eng"], "dct_spatial_sm": ["Iowa"], "dcat_centroid": "41.9383,-93.3896", "b1g_geonames_sm": [], "dct_identifier_sm": ["35c8a641589c4e13b7aa11e37f3f00a1_0"], "dct_publisher_sm": ["State of Iowa"], "pcdm_memberOf_sm": ["03a-04"], "dct_isPartOf_sm": ["03a-04"], "dcat_theme_sm": ["Theme"], "dct_temporal_sm": ["2015"], "dct_description_sm": ["Iowa Agricultural Districts"], "schema_provider_s": "Iowa", "gbl_resourceType_sm": "Vector", "gbl_georeferenced_b": false, "b1g_child_record_b": false, "dct_rights_sm": [""], "b1g_dct_accrualMethod_s": "ArcGIS Hub", "gbl_dateRange_drsim": ["2015-2015"], "b1g_dateAccessioned_sm": ["2020-04-24"], "gbl_mdVersion_s": "Aardvark", "dct_alternative_sm": ["Ag Districts"], "b1g_dct_accrualPeriodicity_s": null}
parent_id:
friendlier_id: 35c8a641589c4e13b7aa11e37f3f00a1_0
file_data:
Expand Down
25 changes: 22 additions & 3 deletions test/jobs/export_job_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
require "test_helper"

class ExportJobTest < ActiveJob::TestCase
# test "the truth" do
# assert true
# end
setup do
@request = "http://localhost:3000"
@current_user = users(:user_001) # Assuming you have a fixture for users
@query_params = {ids: [1, 2, 3]}
@export_service = ExportCsvService
end

test "job is enqueued" do
assert_enqueued_with(job: ExportJob) do
ExportJob.perform_later(@request, @current_user, @query_params, @export_service)
end
end

test "job is performed" do
perform_enqueued_jobs do
ExportJob.perform_later(@request, @current_user, @query_params, @export_service)
end

# Add assertions to verify the expected behavior
# For example, check if the notification was delivered
assert @current_user.notifications.any?
end
end
16 changes: 16 additions & 0 deletions test/models/geoblacklight_admin/solr_utils_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "test_helper"

class SolrUtilsTest < ActiveSupport::TestCase
def setup
@solr_url = Blacklight.connection_config[:url]
@solr_utils = GeoblacklightAdmin::SolrUtils
end

def test_solr_orphan_geomg_ids
assert_respond_to @solr_utils, :solr_orphan_geomg_ids
end

def test_delete_solr_orphans
assert_respond_to @solr_utils, :delete_solr_orphans
end
end
Loading

0 comments on commit 893402a

Please sign in to comment.