From d72a9fb3b54ecae0f78a95c86f8af0e6c51246eb Mon Sep 17 00:00:00 2001 From: mjy Date: Mon, 18 Sep 2023 10:24:04 -0500 Subject: [PATCH 01/29] Change json to jsonb for SqedDepiction. Fix #3556 --- CHANGELOG.md | 11 +++++- app/models/image.rb | 7 +++- app/views/images/show.html.erb | 8 +++++ ...2_change_sqed_depictions_json_to_jsbonb.rb | 6 ++++ db/schema.rb | 35 ++++++++++--------- 5 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20230918143352_change_sqed_depictions_json_to_jsbonb.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f017232f9..3e853d8451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,16 @@ This project does not yet adheres to [Semantic Versioning](https://semv ## [unreleased] -\- + +### Changed + +- Staged image metadata field format from JSON to JSONB [#3446] + +### Fixed + +- Staged image queries failing when multiple facets used [#3556] + +[#3556]: https://github.com/SpeciesFileGroup/taxonworks/issues/3556 ## [0.34.4] - 2023-09-15 diff --git a/app/models/image.rb b/app/models/image.rb index 43721216e2..dddb2b5352 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -70,6 +70,7 @@ class Image < ApplicationRecord medium: { width: 300, height: 300 } }.freeze + has_one :sled_image, dependent: :destroy has_many :depictions, inverse_of: :image, dependent: :restrict_with_error @@ -98,7 +99,11 @@ class Image < ApplicationRecord accepts_nested_attributes_for :sled_image, allow_destroy: true - # @return [Boolean] + def sqed_depiction + depictions.joins(:sqed_depiction).first&.sqed_depiction + end + + # @return [Boolean] def has_duplicate? Image.where(image_file_fingerprint: self.image_file_fingerprint).count > 1 end diff --git a/app/views/images/show.html.erb b/app/views/images/show.html.erb index 605dd2f998..89b1086562 100644 --- a/app/views/images/show.html.erb +++ b/app/views/images/show.html.erb @@ -12,6 +12,14 @@ <% end %> <% end %> + + <% if @image.sqed_depiction -%> + <%= content_tag(:h3, 'SQED Depiction') -%> + + <% end %> + <% end %> <%= content_for :additional_navigation do %> diff --git a/db/migrate/20230918143352_change_sqed_depictions_json_to_jsbonb.rb b/db/migrate/20230918143352_change_sqed_depictions_json_to_jsbonb.rb new file mode 100644 index 0000000000..ec0f83fb0f --- /dev/null +++ b/db/migrate/20230918143352_change_sqed_depictions_json_to_jsbonb.rb @@ -0,0 +1,6 @@ +class ChangeSqedDepictionsJsonToJsbonb < ActiveRecord::Migration[6.1] + def change + change_column :sqed_depictions, :result_ocr, :jsonb, using: 'result_ocr::jsonb' + change_column :sqed_depictions, :result_boundary_coordinates, :jsonb, using: 'result_boundary_coordinates::jsonb' + end +end diff --git a/db/schema.rb b/db/schema.rb index 1cbfe27a87..bebcc0960f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_09_11_214526) do +ActiveRecord::Schema.define(version: 2023_09_18_143352) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" @@ -436,8 +436,8 @@ end create_table "confidences", id: :serial, force: :cascade do |t| - t.string "confidence_object_type", null: false t.integer "confidence_object_id", null: false + t.string "confidence_object_type", null: false t.integer "position", null: false t.integer "created_by_id", null: false t.integer "updated_by_id", null: false @@ -669,8 +669,8 @@ end create_table "documentation", id: :serial, force: :cascade do |t| - t.string "documentation_object_type", null: false t.integer "documentation_object_id", null: false + t.string "documentation_object_type", null: false t.integer "document_id", null: false t.integer "project_id", null: false t.integer "created_by_id", null: false @@ -688,7 +688,7 @@ create_table "documents", id: :serial, force: :cascade do |t| t.string "document_file_file_name", null: false t.string "document_file_content_type", null: false - t.bigint "document_file_file_size", null: false + t.integer "document_file_file_size", null: false t.datetime "document_file_updated_at", null: false t.integer "project_id", null: false t.integer "created_by_id", null: false @@ -720,6 +720,7 @@ t.boolean "is_public" t.string "type" t.integer "total_records" + t.string "sha2" t.index ["created_by_id"], name: "index_downloads_on_created_by_id" t.index ["filename"], name: "index_downloads_on_filename" t.index ["project_id"], name: "index_downloads_on_project_id" @@ -897,8 +898,8 @@ t.string "vernacularName" t.string "waterBody" t.string "year" - t.string "dwc_occurrence_object_type" t.integer "dwc_occurrence_object_id" + t.string "dwc_occurrence_object_type" t.integer "created_by_id", null: false t.integer "updated_by_id", null: false t.integer "project_id" @@ -1097,7 +1098,7 @@ t.datetime "updated_at", null: false t.string "image_file_file_name" t.string "image_file_content_type" - t.bigint "image_file_file_size" + t.integer "image_file_file_size" t.datetime "image_file_updated_at" t.integer "updated_by_id", null: false t.text "image_file_meta" @@ -1178,8 +1179,8 @@ t.integer "project_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "loan_item_object_type" t.integer "loan_item_object_id" + t.string "loan_item_object_type" t.integer "total" t.string "disposition" t.index ["created_by_id"], name: "index_loan_items_on_created_by_id" @@ -1208,7 +1209,7 @@ t.datetime "updated_at", null: false t.string "recipient_honorific" t.string "recipient_country" - t.text "lender_address", null: false + t.text "lender_address", default: "Lender's address not provided.", null: false t.boolean "is_gift" t.index ["created_by_id"], name: "index_loans_on_created_by_id" t.index ["project_id"], name: "index_loans_on_project_id" @@ -1404,10 +1405,10 @@ end create_table "origin_relationships", id: :serial, force: :cascade do |t| - t.string "old_object_type", null: false t.integer "old_object_id", null: false - t.string "new_object_type", null: false + t.string "old_object_type", null: false t.integer "new_object_id", null: false + t.string "new_object_type", null: false t.integer "position" t.integer "created_by_id", null: false t.integer "updated_by_id", null: false @@ -1509,8 +1510,8 @@ end create_table "pinboard_items", id: :serial, force: :cascade do |t| - t.string "pinned_object_type", null: false t.integer "pinned_object_id", null: false + t.string "pinned_object_type", null: false t.integer "user_id", null: false t.integer "project_id", null: false t.integer "position", null: false @@ -1574,7 +1575,7 @@ t.datetime "updated_at", null: false t.integer "created_by_id", null: false t.integer "updated_by_id", null: false - t.jsonb "preferences", default: "{}", null: false + t.jsonb "preferences", default: {}, null: false t.string "api_access_token" t.string "data_curation_issue_tracker_url" t.index ["created_by_id"], name: "index_projects_on_created_by_id" @@ -1583,8 +1584,8 @@ create_table "protocol_relationships", id: :serial, force: :cascade do |t| t.integer "protocol_id", null: false - t.string "protocol_relationship_object_type", null: false t.integer "protocol_relationship_object_id", null: false + t.string "protocol_relationship_object_type", null: false t.integer "position", null: false t.integer "created_by_id", null: false t.integer "updated_by_id", null: false @@ -1843,15 +1844,15 @@ t.string "boundary_finder", null: false t.boolean "has_border", null: false t.string "layout", null: false - t.jsonb "metadata_map", default: "{}", null: false - t.jsonb "specimen_coordinates", default: "{}", null: false + t.jsonb "metadata_map", default: {}, null: false + t.jsonb "specimen_coordinates", default: {}, null: false t.integer "project_id", null: false t.integer "created_by_id", null: false t.integer "updated_by_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.json "result_boundary_coordinates" - t.json "result_ocr" + t.jsonb "result_boundary_coordinates" + t.jsonb "result_ocr" t.datetime "in_progress" t.index ["depiction_id"], name: "index_sqed_depictions_on_depiction_id" t.index ["project_id"], name: "index_sqed_depictions_on_project_id" From bcd905c55466087235389c575d96fd9b2a5d2155 Mon Sep 17 00:00:00 2001 From: mjy Date: Mon, 18 Sep 2023 10:31:50 -0500 Subject: [PATCH 02/29] Comment on xml column [skip ci] --- lib/queries/depiction/filter.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/queries/depiction/filter.rb b/lib/queries/depiction/filter.rb index c2eb1aa079..2520c91fb6 100644 --- a/lib/queries/depiction/filter.rb +++ b/lib/queries/depiction/filter.rb @@ -70,6 +70,10 @@ def depiction_object_id_facet table[:depiction_object_id].eq_any(depiction_object_id) end + # If we add merge_clauses then we likely have + # to deal with excluding the `xml` field from distinct+intersection calls + # via a custom base_query field. + def and_clauses [ depiction_id_facet, From 9b2f82cb39741e2cc3019286e2a408d02483dd86 Mon Sep 17 00:00:00 2001 From: mjy Date: Tue, 19 Sep 2023 10:03:19 -0500 Subject: [PATCH 03/29] Fix bug with ordering in OTUs filter. --- CHANGELOG.md | 1 + app/controllers/otus_controller.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e853d8451..4467455966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project does not yet adheres to [Semantic Versioning](https://semv ### Fixed +- Taxon name/otus filter order bug - Staged image queries failing when multiple facets used [#3556] [#3556]: https://github.com/SpeciesFileGroup/taxonworks/issues/3556 diff --git a/app/controllers/otus_controller.rb b/app/controllers/otus_controller.rb index 079ae3c5b1..180a13db04 100644 --- a/app/controllers/otus_controller.rb +++ b/app/controllers/otus_controller.rb @@ -22,7 +22,7 @@ def index .page(params[:page]) .per(params[:per]) .eager_load(:taxon_name) - .order('taxon_names.cached, otus.name') + .order(:cached, 'otus.name') } end end From 59d9283ed478f5d8fc8c726c8b4fd99aa8710a55 Mon Sep 17 00:00:00 2001 From: jlpereira Date: Wed, 20 Sep 2023 12:22:49 -0300 Subject: [PATCH 04/29] Add depiction list on filter images --- CHANGELOG.md | 5 ++++- app/javascript/vue/tasks/images/filter/app.vue | 6 ++++-- .../tasks/images/filter/components/DepictionList.vue | 10 ++++++---- .../vue/tasks/images/filter/components/image.vue | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4467455966..89333c1ddf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project does not yet adheres to [Semantic Versioning](https://semv ## [unreleased] +### Added + +- Depictions list on Filter image ### Changed @@ -23,7 +26,7 @@ This project does not yet adheres to [Semantic Versioning](https://semv ### Added -- ImportAttribute facets to various filters +- ImportAttribute facets to various filters - Project data curation issue tracking URL field (and to base API response) [#3550] - Manual option to regenerate derivative images on Show Image - API gallery endpoint `/depictions/gallery` diff --git a/app/javascript/vue/tasks/images/filter/app.vue b/app/javascript/vue/tasks/images/filter/app.vue index 78d5f50e4c..c6c4e6bb92 100644 --- a/app/javascript/vue/tasks/images/filter/app.vue +++ b/app/javascript/vue/tasks/images/filter/app.vue @@ -19,8 +19,9 @@ v-if="list.length" class="horizontal-right-content" > - | -
+ | +
+