From 7d180371f97c975c793840a12ef81d2c22e2a744 Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Sat, 6 Jul 2024 12:12:37 -0700 Subject: [PATCH 01/22] Bring back the animation for the facet menu This commit will bring back the collapse animation for the facet menu on the catalog search results page. For a sutble touch, I've made the speed of the ">" icon rotation at the same speed as the menu collapse. --- app/assets/stylesheets/hyrax/_facets.scss | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/assets/stylesheets/hyrax/_facets.scss b/app/assets/stylesheets/hyrax/_facets.scss index 0149580b4b..e01dba9700 100644 --- a/app/assets/stylesheets/hyrax/_facets.scss +++ b/app/assets/stylesheets/hyrax/_facets.scss @@ -3,6 +3,18 @@ width: 100%; } +.facet-field-heading button.collapsed::after { + transition: transform 0.25s ease; +} + +.facet-field-heading button::after { + transition: transform 0.25s ease; +} + +.collapsing { + transition: height 0.25s ease; +} + .facets-header > .navbar-toggler { display: none; } From 4f9ceec41b292f7efebb2b9675e28051fd97a721 Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Sat, 6 Jul 2024 15:19:16 -0700 Subject: [PATCH 02/22] Align collection badge This commit will align the collection badge mainly with a bigger margin on the right so the badge doesn't look so close to the title. --- app/assets/stylesheets/hyrax/_catalog.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/assets/stylesheets/hyrax/_catalog.scss b/app/assets/stylesheets/hyrax/_catalog.scss index 884afce94f..013a4ab376 100644 --- a/app/assets/stylesheets/hyrax/_catalog.scss +++ b/app/assets/stylesheets/hyrax/_catalog.scss @@ -23,6 +23,16 @@ } } + .search-results-title-row { + .badge { + margin-bottom: 6px; + } + + .search-result-title { + margin-right: 16px; + } + } + .collection-icon-search { padding-bottom: 20px; } From cb89d21c40a3291382ddf7fb8d9bb33a7e241918 Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Sat, 6 Jul 2024 15:20:39 -0700 Subject: [PATCH 03/22] Even out spacing on featured works This commit will even the spacing out on the featured works on the homepage. Also moving the handle index up so it looks like the old version. --- app/assets/stylesheets/hyrax/_card.scss | 4 ++++ app/assets/stylesheets/hyrax/_featured.scss | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/assets/stylesheets/hyrax/_card.scss b/app/assets/stylesheets/hyrax/_card.scss index 2e21aabd04..de751d9be1 100644 --- a/app/assets/stylesheets/hyrax/_card.scss +++ b/app/assets/stylesheets/hyrax/_card.scss @@ -2,6 +2,10 @@ margin-bottom: 20px; } +#featured_works .card { + margin-bottom: 5px; +} + .card-title { margin-top: 0; margin-bottom: 0; diff --git a/app/assets/stylesheets/hyrax/_featured.scss b/app/assets/stylesheets/hyrax/_featured.scss index c3db4f28fb..04cfb03b7f 100644 --- a/app/assets/stylesheets/hyrax/_featured.scss +++ b/app/assets/stylesheets/hyrax/_featured.scss @@ -44,3 +44,7 @@ ol#featured_works { padding: 1em 0; border-bottom: 1px dotted $gray-lighter; } + +.dd-handle.dd3-handle { + z-index: 1; +} From fa1bffccdc36ef8de2a386ff11ea9035f63d0780 Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Sat, 6 Jul 2024 15:39:09 -0700 Subject: [PATCH 04/22] Ensure gradient is applied to featured works drag This commit will update the way the CSS gradient is called so that it is applied. --- app/assets/stylesheets/hyrax/_nestable.scss | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/hyrax/_nestable.scss b/app/assets/stylesheets/hyrax/_nestable.scss index ea711188ee..82b5873dfe 100644 --- a/app/assets/stylesheets/hyrax/_nestable.scss +++ b/app/assets/stylesheets/hyrax/_nestable.scss @@ -47,12 +47,12 @@ tr.dd-item { .dd-placeholder, .dd-empty { margin: 5px 0; padding: 0; min-height: 30px; border: 1px dashed #b6bcbf; box-sizing: border-box; -moz-box-sizing: border-box; } -.dd-empty { border: 1px dashed #bbb; min-height: 100px; - background-image: -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), +.dd-empty { border: 1px dashed #bbb; min-height: 100px; + background-image: -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff); - background-image: -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), + background-image: -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff); - background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), + background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff); background-size: 60px 60px; background-position: 0 0, 30px 30px; @@ -95,15 +95,16 @@ tr.dd-item { .dd3-item > button { margin-left: 30px; } -.dd3-handle { +.dd3-handle { position: absolute; margin: 0; left: 0; top: 0; cursor: pointer; width: 30px; text-indent: 100px; white-space: nowrap; overflow: hidden; border: 1px solid #aaa; background: #ddd; background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%); - background: -moz-linear-gradient(top, #ddd 0%, #bbb 100%); - background: linear-gradient(top, #ddd 0%, #bbb 100%); + background: -moz-linear-gradient(top, #ddd 0%, #bbb 100%); + background: -o-linear-gradient(to bottom, #ddd 0%, #bbb 100%); + background: linear-gradient(to bottom, #ddd 0%, #bbb 100%); border-top-right-radius: 0; border-bottom-right-radius: 0; } From bea69bdf9814b0a78bf2bd95ca0317bae7a46ceb Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Sat, 6 Jul 2024 20:29:15 -0700 Subject: [PATCH 05/22] Fix #li for views Not sure when this changed but without adding the ** infront of list_options we get a hash printed out instead of the class attribute: ``` list_options {:class=>"nav-item"} (ruby) tag.li(list_options) "<li>{:class=>"nav-item"}</li>" (ruby) tag.li(**list_options) "<li class=\"nav-item\"></li>" ``` This commit should fix the active class not being added to the active menu item. Also it fixes the way it stacks when the sidebar is closed. --- app/presenters/hyrax/menu_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/hyrax/menu_presenter.rb b/app/presenters/hyrax/menu_presenter.rb index b0074c27bf..e27587d83b 100644 --- a/app/presenters/hyrax/menu_presenter.rb +++ b/app/presenters/hyrax/menu_presenter.rb @@ -33,7 +33,7 @@ def settings_section? def nav_link(options, also_active_for: nil, **link_html_options) active_urls = [options, also_active_for].compact list_options = active_urls.any? { |url| current_page?(url) } ? { class: 'active nav-item' } : { class: 'nav-item' } - tag.li(list_options) do + tag.li(**list_options) do link_to(options, link_html_options) do yield end From 4dd04435619ddb335e6dcec5c7bed226e3635756 Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Mon, 8 Jul 2024 14:42:01 -0700 Subject: [PATCH 06/22] Add active class to Dashboard <li> This commit will align the dashboard <li> behavior with the other sidebar items. When the user is on the dashboard, the dashboard <li> will have the active class. --- app/views/hyrax/dashboard/_sidebar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/hyrax/dashboard/_sidebar.html.erb b/app/views/hyrax/dashboard/_sidebar.html.erb index 8a3522e07b..5a4c6f569f 100644 --- a/app/views/hyrax/dashboard/_sidebar.html.erb +++ b/app/views/hyrax/dashboard/_sidebar.html.erb @@ -12,7 +12,7 @@ </div> </div> </li> - <li class="nav-item"> + <li class="nav-item <%= 'active' if current_page?(hyrax.dashboard_path) %>"> <%= link_to hyrax.dashboard_path, class: "nav-link", title: t('hyrax.admin.sidebar.dashboard') do %> <span class="fa fa-home" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.dashboard') %></span> <% end %> From 1924db5f8427a37465569f164cfc213ca94ff46a Mon Sep 17 00:00:00 2001 From: Daniel Pierce <dlpierce@indiana.edu> Date: Wed, 10 Jul 2024 11:30:39 -0400 Subject: [PATCH 07/22] Do not require custom cops in the engine This broke builds that do not install the rubocop gem. Loading of this custom cop is handled by rubocop.yml, and now in its spec. --- lib/hyrax/engine.rb | 1 - spec/lib/hyrax/rubocop/custom_cops_spec.rb | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hyrax/engine.rb b/lib/hyrax/engine.rb index d8fcd12f25..71983435b3 100644 --- a/lib/hyrax/engine.rb +++ b/lib/hyrax/engine.rb @@ -34,7 +34,6 @@ class Engine < ::Rails::Engine require 'hyrax/transactions' require 'hyrax/errors' require 'hyrax/valkyrie_simple_path_generator' - require 'hyrax/rubocop/custom_cops' # Force these models to be added to Legato's registry in development mode config.eager_load_paths += %W[ diff --git a/spec/lib/hyrax/rubocop/custom_cops_spec.rb b/spec/lib/hyrax/rubocop/custom_cops_spec.rb index 5c4904dd61..8cfcc7a619 100644 --- a/spec/lib/hyrax/rubocop/custom_cops_spec.rb +++ b/spec/lib/hyrax/rubocop/custom_cops_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true +require 'hyrax/rubocop/custom_cops' RSpec.describe Hyrax::RuboCop::CustomCops::ArResource do subject(:cop) { described_class.new } From 59a42adfd57e8c97ceee52ae81176e5ccddcd7a6 Mon Sep 17 00:00:00 2001 From: Randall Floyd <rdfloyd@indiana.edu> Date: Thu, 11 Jul 2024 12:47:44 -0400 Subject: [PATCH 08/22] Enabling pairtree paths for Fedora 6 in Sirenia (#6804) * Enabling pairtree paths for Fedora 6 in Sirenia * Update valkyrie --------- Co-authored-by: Daniel Pierce <dlpierce@indiana.edu> --- .koppie/config/initializers/1_valkyrie.rb | 8 ++++++-- docker-compose-sirenia.yml | 3 ++- hyrax.gemspec | 2 +- .../hyrax/templates/config/initializers/1_valkyrie.rb | 8 ++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.koppie/config/initializers/1_valkyrie.rb b/.koppie/config/initializers/1_valkyrie.rb index 5fbfeb7012..024d4a91f2 100644 --- a/.koppie/config/initializers/1_valkyrie.rb +++ b/.koppie/config/initializers/1_valkyrie.rb @@ -34,7 +34,9 @@ ENV.fetch('FCREPO_URL') { "http://localhost:8080/fcrepo/rest" })), base_path: Rails.env, schema: Valkyrie::Persistence::Fedora::PermissiveSchema.new(Hyrax::SimpleSchemaLoader.new.permissive_schema_for_valkrie_adapter), - fedora_version: 6 + fedora_version: 6.5, + fedora_pairtree_count: 4, + fedora_pairtree_length: 2 ), :fedora_metadata ) @@ -64,7 +66,9 @@ connection: ::Ldp::Client.new(Hyrax.config.fedora_connection_builder.call( ENV.fetch('FCREPO_URL') { "http://localhost:8080/fcrepo/rest" })), base_path: Rails.env, - fedora_version: 6 + fedora_version: 6.5, + fedora_pairtree_count: 4, + fedora_pairtree_length: 2 ), :fedora_storage ) diff --git a/docker-compose-sirenia.yml b/docker-compose-sirenia.yml index 15cf030c98..df9586e745 100644 --- a/docker-compose-sirenia.yml +++ b/docker-compose-sirenia.yml @@ -134,7 +134,8 @@ services: CATALINA_OPTS=-Dfcrepo.home=/fcrepo-home -Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true - - JAVA_OPTS=-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true + -Dfcrepo.pid.minter.length=2 -Dfcrepo.pid.minter.count=4 + - JAVA_OPTS=-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Dfcrepo.pid.minter.length=2 -Dfcrepo.pid.minter.count=4 volumes: - fcrepo:/fcrepo-home ports: diff --git a/hyrax.gemspec b/hyrax.gemspec index a86bc9be16..f444e098dd 100644 --- a/hyrax.gemspec +++ b/hyrax.gemspec @@ -85,7 +85,7 @@ SUMMARY spec.add_dependency 'retriable', '>= 2.9', '< 4.0' spec.add_dependency 'signet' spec.add_dependency 'tinymce-rails', '~> 5.10' - spec.add_dependency 'valkyrie', '~> 3.1.1' + spec.add_dependency 'valkyrie', '~> 3.3' spec.add_dependency 'view_component', '~> 2.74.1' # Pin until blacklight is updated with workaround for https://github.com/ViewComponent/view_component/issues/1565 spec.add_dependency 'sprockets', '3.7.2' # 3.7.3 fails feature specs spec.add_dependency 'sass-rails', '~> 6.0' diff --git a/lib/generators/hyrax/templates/config/initializers/1_valkyrie.rb b/lib/generators/hyrax/templates/config/initializers/1_valkyrie.rb index d7d5b7a68c..c59e31d0d4 100644 --- a/lib/generators/hyrax/templates/config/initializers/1_valkyrie.rb +++ b/lib/generators/hyrax/templates/config/initializers/1_valkyrie.rb @@ -36,7 +36,9 @@ # )), # base_path: Rails.env, # schema: Valkyrie::Persistence::Fedora::PermissiveSchema.new(Hyrax::SimpleSchemaLoader.new.permissive_schema_for_valkrie_adapter), -# fedora_version: 6 +# fedora_version: 6.5, +# fedora_pairtree_count: 4, +# fedora_pairtree_length: 2 # ), :fedora_metadata # ) @@ -68,7 +70,9 @@ # ENV.fetch('FCREPO_URL') { "http://localhost:8080/fcrepo/rest" } # )), # base_path: Rails.env, -# fedora_version: 6 +# fedora_version: 6.5, +# fedora_pairtree_count: 4, +# fedora_pairtree_length: 2 # ), :fedora_storage # ) From 9c58751ef35421b19cad1b781876077ab3e85591 Mon Sep 17 00:00:00 2001 From: bwatson78 <brad.watson.orlando@gmail.com> Date: Thu, 25 Jul 2024 12:24:54 -0500 Subject: [PATCH 09/22] Corrects the sharing of predicates between date_created and created_at. --- config/metadata/hyrax_internal_metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/metadata/hyrax_internal_metadata.yaml b/config/metadata/hyrax_internal_metadata.yaml index f33b3f8c65..525b50552c 100644 --- a/config/metadata/hyrax_internal_metadata.yaml +++ b/config/metadata/hyrax_internal_metadata.yaml @@ -14,7 +14,7 @@ attributes: compression: predicate: http://vocabulary.samvera.org/ns#compressionScheme created_at: - predicate: http://purl.org/dc/terms/created + predicate: http://vocabulary.samvera.org/ns#created_at file_identifier: predicate: http://vocabulary.samvera.org/ns#fileIdentifier file_ids: From 082046375656be1995579a4aa7f1c5ec7b2f608b Mon Sep 17 00:00:00 2001 From: LaRita Robinson <larita@scientist.com> Date: Mon, 5 Aug 2024 13:45:58 -0400 Subject: [PATCH 10/22] Add lonely operator for error message Capturing errors can sometimes result in a situation where the error message throws an error and the true error gets lost. --- app/services/hyrax/custom_queries/find_file_metadata.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/hyrax/custom_queries/find_file_metadata.rb b/app/services/hyrax/custom_queries/find_file_metadata.rb index b155cae6c3..f2343344d5 100644 --- a/app/services/hyrax/custom_queries/find_file_metadata.rb +++ b/app/services/hyrax/custom_queries/find_file_metadata.rb @@ -31,7 +31,7 @@ def find_file_metadata_by(id:) result = query_service.find_by(id: id) unless result.is_a? Hyrax::FileMetadata raise ::Valkyrie::Persistence::ObjectNotFoundError, - "Result type #{result.internal_resource} for id #{id} is not a `Hyrax::FileMetadata`" + "Result type #{result&.internal_resource} for id #{id} is not a `Hyrax::FileMetadata`" end result end @@ -44,7 +44,7 @@ def find_file_metadata_by_alternate_identifier(alternate_identifier:) result = query_service.find_by_alternate_identifier(alternate_identifier: alternate_identifier) unless result.is_a? Hyrax::FileMetadata raise ::Valkyrie::Persistence::ObjectNotFoundError, - "Result type #{result.internal_resource} for alternate_identifier #{alternate_identifier} is not a `Hyrax::FileMetadata`" + "Result type #{result&.internal_resource} for alternate_identifier #{alternate_identifier} is not a `Hyrax::FileMetadata`" end result end From 4273c06c8ebd4e13c72d270ddd8fe15304b3efb9 Mon Sep 17 00:00:00 2001 From: Kirk Wang <k3wang@gmail.com> Date: Mon, 5 Aug 2024 11:51:23 -0700 Subject: [PATCH 11/22] Fix catalog search dropdown (#6867) * Fix catalog search form dropdown not changing On the home page when the user is logged in, the dropdown next to the search was not changing when the user selects a different option. This was because the javascript was changing the data-search-element="label" span but what is actually being shown is the aria-hidden="true" span. Before: <span class="sr-only" data-search-element="label">All</span> <span aria-hidden="true">All</span> *user selects a different option* <span class="sr-only" data-search-element="label">My Works</span> <span aria-hidden="true">All</span> After: <span class="sr-only" data-search-element="label">All</span> <span aria-hidden="true">All</span> *user selects a different option* <span class="sr-only" data-search-element="label">My Works</span> <span aria-hidden="true">My Works</span> * Change html structure for search dropdown This change will align how Bootstrap 4 does dropdown menus. The exmaples that I see in the documentation show that it should be in a <div> tag with <a> tags inside of it. --- app/assets/javascripts/hyrax/search.js | 5 ++--- app/views/catalog/_search_form.html.erb | 25 +++++++++---------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/hyrax/search.js b/app/assets/javascripts/hyrax/search.js index 83e43698aa..d7aead5ab9 100644 --- a/app/assets/javascripts/hyrax/search.js +++ b/app/assets/javascripts/hyrax/search.js @@ -4,6 +4,7 @@ this.init = function() { this.$label = this.$element.find('[data-search-element="label"]'); + this.$visibleLabel = this.$element.find('.dropdown-toggle').find('span[aria-hidden="true"]'); this.$items = this.$element.find('[data-search-option]'); this.setDefault(); } @@ -12,7 +13,6 @@ this.attachEvents(); } - Hyrax.Search.prototype = { attachEvents: function() { @@ -43,6 +43,7 @@ setLabel: function(label) { this.$label.html(label); + this.$visibleLabel.html(label); } } @@ -58,8 +59,6 @@ })(jQuery); - Blacklight.onLoad(function() { $('#search-form-header').search(); }); - diff --git a/app/views/catalog/_search_form.html.erb b/app/views/catalog/_search_form.html.erb index 730a5d13e0..1b32ab52ee 100644 --- a/app/views/catalog/_search_form.html.erb +++ b/app/views/catalog/_search_form.html.erb @@ -20,24 +20,17 @@ <span class="sr-only" data-search-element="label"><%= t("hyrax.search.form.option.all.label_long", application_name: application_name) %></span> <span aria-hidden="true"><%= t("hyrax.search.form.option.all.label_short") %></span> </button> - - <ul class="dropdown-menu dropdown-menu-right"> - <li class="dropdown-item"> - <%= link_to t("hyrax.search.form.option.all.label_long", application_name: application_name), "#", - data: { "search-option" => main_app.search_catalog_path, "search-label" => t("hyrax.search.form.option.all.label_short") } %> - </li> - <li class="dropdown-item"> - <%= link_to t("hyrax.search.form.option.my_works.label_long"), "#", - data: { "search-option" => hyrax.my_works_path, "search-label" => t("hyrax.search.form.option.my_works.label_short") } %> - </li> - <li class="dropdown-item"> - <%= link_to t("hyrax.search.form.option.my_collections.label_long"), "#", - data: { "search-option" => hyrax.my_collections_path, "search-label" => t("hyrax.search.form.option.my_collections.label_short") } %> - </li> - </ul> + <div class="dropdown-menu dropdown-menu-right"> + <%= link_to t("hyrax.search.form.option.all.label_long", application_name: application_name), "#", class: "dropdown-item", + data: { "search-option" => main_app.search_catalog_path, "search-label" => t("hyrax.search.form.option.all.label_short") } %> + <%= link_to t("hyrax.search.form.option.my_works.label_long"), "#", class: "dropdown-item", + data: { "search-option" => hyrax.my_works_path, "search-label" => t("hyrax.search.form.option.my_works.label_short") } %> + <%= link_to t("hyrax.search.form.option.my_collections.label_long"), "#", class: "dropdown-item", + data: { "search-option" => hyrax.my_collections_path, "search-label" => t("hyrax.search.form.option.my_collections.label_short") } %> + </div> <% end %> </div><!-- /.input-group-btn --> </div><!-- /.input-group --> - + </div><!-- /.form-group --> <% end %> From 4b7495891ca2a4d0873da0feab86fd7e734648f6 Mon Sep 17 00:00:00 2001 From: Daniel Pierce <dlpierce@indiana.edu> Date: Mon, 5 Aug 2024 14:55:57 -0400 Subject: [PATCH 12/22] Explicitly cast metrics from Matomo to be integers (#6853) see: matomo-org/matomo#21978 Co-authored-by: Ryan Baumann <ryan.baumann@gmail.com> --- app/services/hyrax/analytics/matomo.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/hyrax/analytics/matomo.rb b/app/services/hyrax/analytics/matomo.rb index ac9c83c32f..06a0582cd9 100644 --- a/app/services/hyrax/analytics/matomo.rb +++ b/app/services/hyrax/analytics/matomo.rb @@ -165,9 +165,9 @@ def results_array(response, metric) if result[1].empty? results.push([result[0].to_date, 0]) elsif result[1].is_a?(Array) - results.push([result[0].to_date, result[1].first[metric]]) + results.push([result[0].to_date, result[1].first[metric].to_i]) else - results.push([result[0].to_date, result[1][metric].presence || 0]) + results.push([result[0].to_date, result[1][metric].presence.to_i]) end end Hyrax::Analytics::Results.new(results) From 4693418892b2c747ad2a4c40101fdd8594edbe05 Mon Sep 17 00:00:00 2001 From: Rob Kaufman <rob@notch8.com> Date: Tue, 6 Aug 2024 13:04:26 -0700 Subject: [PATCH 13/22] add fake jobs to main so that events will trigger (#6871) * add fake jobs to main so that events will trigger * dont double run the tests --- .github/workflows/lint-build-test.yml | 90 +++++++++++++++++++++++++++ .github/workflows/test-results.yml | 40 ++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 .github/workflows/lint-build-test.yml create mode 100644 .github/workflows/test-results.yml diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml new file mode 100644 index 0000000000..dbfa23462e --- /dev/null +++ b/.github/workflows/lint-build-test.yml @@ -0,0 +1,90 @@ +name: 'Lint Build Test' +run-name: Link Build Test of ${{ github.ref_name }} by @${{ github.actor }} +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + inputs: + debug_enabled: + type: boolean + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + required: false + default: false + +env: + REGISTRY: ghcr.io + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + cache-version: 1 + - name: Rubocop + run: echo "<?xml version='1.0'?><testsuites><testsuite name='rubocop' tests='1735' failures='0'/></testsuites>" >> rubocop.xml + - name: Archive rubocop reports + uses: actions/upload-artifact@v4 + if: always() + with: + name: rubocop-reports + path: 'rubocop*.xml' + + build: + needs: lint + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ci_test_app: [dassie,koppie] + steps: + - name: Checkout + uses: actions/checkout@v4 + + test: + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ci_test_app: [dassie,koppie] + ci_node_total: [8] + ci_node_index: [0,1,2,3,4,5,6,7] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Fake Run + run: echo "<?xml version='1.0'?><testsuites><testsuite name='rspec' tests='1735' failures='0'/></testsuites>" >> rspec.xml + - name: Move Test Files + if: always() + env: + CI_TEST_APP: ${{ matrix.ci_test_app }} + CI_NODE_TOTAL: ${{ matrix.ci_node_total }} + CI_NODE_INDEX: ${{ matrix.ci_node_index }} + run: >- + mv rspec.xml rspec-${CI_TEST_APP}-${CI_NODE_INDEX}.xml + - name: Archive spec reports (${{ matrix.ci_node_index}}) + uses: actions/upload-artifact@v4 + if: always() + with: + name: spec-reports-${{ matrix.ci_test_app }}-${{ matrix.ci_node_index }} + path: '**/rspec*.xml' + + event_file: + name: "Event File" + runs-on: ubuntu-latest + steps: + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: Event File + path: ${{ github.event_path }} diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml new file mode 100644 index 0000000000..9f8a52b68f --- /dev/null +++ b/.github/workflows/test-results.yml @@ -0,0 +1,40 @@ +name: Test Results + +on: + workflow_run: + workflows: ["Lint Build Test"] + types: + - completed +permissions: {} + +jobs: + test-results: + name: Test Results Check + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + + permissions: + checks: write + # needed unless run with comment_mode: off + pull-requests: write + # required by download step to access artifacts API + actions: read + + steps: + - name: Download and Extract Artifacts + uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d + with: + run_id: ${{ github.event.workflow_run.id }} + path: artifacts + name: "*(report|Event)*" + name_is_regexp: true + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + files: "artifacts/**/*.xml" + action_fail_on_inconclusive: true + fail_on: "test failures" From 10d458afd45c3ad8f5c1f844fa41d997b9cfeaac Mon Sep 17 00:00:00 2001 From: rkuehn-uofl <randy.kuehn@louisville.edu> Date: Wed, 7 Aug 2024 13:15:45 -0400 Subject: [PATCH 14/22] Testing review (#6845) * Update _forms.scss Update to correct text color contrast does not meet minimum requirements on edit file page #6810 * Update release.yml Updates tags to include accessibility --- .github/release.yml | 3 +++ app/assets/stylesheets/hyrax/_forms.scss | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/release.yml b/.github/release.yml index ae27e4fe80..af24bcddfb 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -24,6 +24,9 @@ changelog: - title: Tests and CI Process labels: - notes-tests + - title: Accessibility Standards + labels: + - notes-accessibility - title: Other labels: - "*" diff --git a/app/assets/stylesheets/hyrax/_forms.scss b/app/assets/stylesheets/hyrax/_forms.scss index 788f6f4b99..0812bf0bb7 100644 --- a/app/assets/stylesheets/hyrax/_forms.scss +++ b/app/assets/stylesheets/hyrax/_forms.scss @@ -1,6 +1,6 @@ legend small { margin-left: 0.5em; - color: #999999; + color: #595959; font-size: 15px; } From cc5b6733f325794b0992cf51abbd0ce8d7c951d7 Mon Sep 17 00:00:00 2001 From: Rob Kaufman <rob@notch8.com> Date: Wed, 7 Aug 2024 14:25:59 -0700 Subject: [PATCH 15/22] Builds from forks 3 (#6878) * add fake jobs to main so that events will trigger * regexp respect --- .github/workflows/test-results.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml index 9f8a52b68f..c1c9e93220 100644 --- a/.github/workflows/test-results.yml +++ b/.github/workflows/test-results.yml @@ -26,7 +26,7 @@ jobs: with: run_id: ${{ github.event.workflow_run.id }} path: artifacts - name: "*(report|Event)*" + name: ".*(report|Event).*" name_is_regexp: true - name: Publish Test Results From 519dc97177f8e59235b89d5af4bd26894f5c430d Mon Sep 17 00:00:00 2001 From: Corey Gillen <corey.j.gillen@gmail.com> Date: Wed, 7 Aug 2024 14:43:58 -0700 Subject: [PATCH 16/22] Use faster solr faceting for dashboard stats (#6865) --- app/models/hyrax/statistic.rb | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/app/models/hyrax/statistic.rb b/app/models/hyrax/statistic.rb index eb7de18887..f849ba4e2f 100644 --- a/app/models/hyrax/statistic.rb +++ b/app/models/hyrax/statistic.rb @@ -27,29 +27,20 @@ def statistics(object, start_date, user_id = nil) def query_works(query) models = Hyrax::ModelRegistry.work_rdf_representations.map { |m| "\"#{m}\"" } - Hyrax::SolrService.query("has_model_ssim:(#{models.join(' OR ')})", fl: query, rows: 100_000) + response = Hyrax::SolrService.get(fq: "has_model_ssim:(#{models.join(' OR ')})", 'facet.field': query, 'facet.missing': true, rows: 0) + Hash[*response['facet_counts']['facet_fields'][query]] end def work_types - results = query_works("human_readable_type_tesim") - results.group_by { |result| result['human_readable_type_tesim']&.join('') || "Unknown" }.transform_values(&:count) + types = query_works("human_readable_type_sim") + types['Unknown'] = types.delete(nil) + types end def resource_types - results = query_works("resource_type_tesim") - resource_types = [] - results.each do |y| - if y["resource_type_tesim"].nil? || (y["resource_type_tesim"] == [""]) - resource_types.push("Unknown") - elsif y["resource_type_tesim"].count > 1 - y["resource_type_tesim"].each do |t| - resource_types.push(t) - end - else - resource_types.push(y["resource_type_tesim"].join("")) - end - end - resource_types.group_by { |rt| rt }.transform_values(&:count) + types = query_works("resource_type_sim") + types['Unknown'] = types.delete(nil) + types end private From ac2e23178217ea7ed0e305bc96fd520069571eaf Mon Sep 17 00:00:00 2001 From: Ryan Baumann <ryan.baumann@gmail.com> Date: Wed, 7 Aug 2024 17:44:14 -0400 Subject: [PATCH 17/22] Use $(document).ready instead of $(document).on("ready") (deprecated in jQuery 1.8 and removed in jQuery 3.0) (#6832) --- app/assets/javascripts/hyrax/analytics_events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/hyrax/analytics_events.js b/app/assets/javascripts/hyrax/analytics_events.js index 9af7798bd2..b73d4a5463 100644 --- a/app/assets/javascripts/hyrax/analytics_events.js +++ b/app/assets/javascripts/hyrax/analytics_events.js @@ -69,7 +69,7 @@ if (typeof Turbolinks !== 'undefined') { setupTracking() }) } else { - $(document).on('ready', function() { + $(document).ready(function() { setupTracking() }) } From e4f8a06aaf1c9ec378f87764da59f73a8adf06d7 Mon Sep 17 00:00:00 2001 From: Rob Kaufman <rob@notch8.com> Date: Wed, 7 Aug 2024 17:16:00 -0700 Subject: [PATCH 18/22] Final step in build from forks work (#6881) Test Report now runs via workflow trigger. This allows it to run on forked branches and dependabot PRs. --- .github/workflows/build-test-lint.yml | 145 -------------------------- .github/workflows/lint-build-test.yml | 52 ++++++++- 2 files changed, 48 insertions(+), 149 deletions(-) delete mode 100644 .github/workflows/build-test-lint.yml diff --git a/.github/workflows/build-test-lint.yml b/.github/workflows/build-test-lint.yml deleted file mode 100644 index 752c2f4f6a..0000000000 --- a/.github/workflows/build-test-lint.yml +++ /dev/null @@ -1,145 +0,0 @@ -name: 'Build Test Lint' -run-name: Build Test Lint of ${{ github.ref_name }} by @${{ github.actor }} -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - inputs: - debug_enabled: - type: boolean - description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' - required: false - default: false - -env: - REGISTRY: ghcr.io - DOCKER_BUILDKIT: 1 - COMPOSE_DOCKER_CLI_BUILD: 1 - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.2' - bundler-cache: true - cache-version: 1 - - name: Rubocop - run: bundle install && bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed - - name: Archive rubocop reports - uses: actions/upload-artifact@v4 - if: always() - with: - name: rubocop-reports - path: 'rubocop*.xml' - - build: - needs: lint - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - ci_test_app: [dassie,koppie] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build and export - uses: docker/build-push-action@v5 - with: - build-args: | - APP_PATH=.${{ matrix.ci_test_app }} - cache-from: type=gha - cache-to: type=gha, mode=max - context: . - target: hyrax-engine-dev - tags: samvera/${{ matrix.ci_test_app }}:latest,samvera/${{ matrix.ci_test_app }}:${{ github.sha }} - outputs: type=docker,dest=/tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar - - name: Upload built image artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.ci_test_app }}-image - path: /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar - - test: - needs: build - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - ci_test_app: [dassie,koppie] - ci_node_total: [8] - ci_node_index: [0,1,2,3,4,5,6,7] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup tmate debug session - uses: mxschmitt/action-tmate@v3 - if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} - with: - limit-access-to-actor: true - detached: true - - name: Download built image artifact - uses: actions/download-artifact@v4 - with: - name: ${{ matrix.ci_test_app }}-image - path: /tmp - - name: Start containers - run: | - docker load --input /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar - docker image ls -a - docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml up -d --quiet-pull --pull missing --no-build - - name: RSpec - env: - CI_NODE_TOTAL: ${{ matrix.ci_node_total }} - CI_NODE_INDEX: ${{ matrix.ci_node_index }} - run: >- - docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml exec -T -w /app/samvera/hyrax-engine web sh -c - "bundle install && yarn install && rspec_booster --job ${{ matrix.ci_node_index }}/${{ matrix.ci_node_total }}" - - name: Capture Container Logs - if: always() - uses: jwalton/gh-docker-logs@v2 - with: - images: 'seleniarm/standalone-chromium' - - name: Move Test Files - if: always() - env: - CI_TEST_APP: ${{ matrix.ci_test_app }} - CI_NODE_TOTAL: ${{ matrix.ci_node_total }} - CI_NODE_INDEX: ${{ matrix.ci_node_index }} - run: >- - mv rspec.xml rspec-${CI_TEST_APP}-${CI_NODE_INDEX}.xml - - name: Archive spec reports - uses: actions/upload-artifact@v4 - if: always() - with: - name: spec-reports-${{ matrix.ci_test_app }}-${{ matrix.ci_node_index }} - path: '**/rspec*.xml' - - report: - needs: test - runs-on: ubuntu-latest - permissions: - checks: write - # only needed unless run with comment_mode: off - pull-requests: write - if: always() - steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - pattern: "*report*" - - name: Publish Test Report - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - files: "artifacts/**/*.xml" - action_fail_on_inconclusive: true - fail_on: "test failures" diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index dbfa23462e..04be1da356 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -31,7 +31,7 @@ jobs: bundler-cache: true cache-version: 1 - name: Rubocop - run: echo "<?xml version='1.0'?><testsuites><testsuite name='rubocop' tests='1735' failures='0'/></testsuites>" >> rubocop.xml + run: bundle install && bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed - name: Archive rubocop reports uses: actions/upload-artifact@v4 if: always() @@ -49,6 +49,24 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and export + uses: docker/build-push-action@v5 + with: + build-args: | + APP_PATH=.${{ matrix.ci_test_app }} + cache-from: type=gha + cache-to: type=gha, mode=max + context: . + target: hyrax-engine-dev + tags: samvera/${{ matrix.ci_test_app }}:latest,samvera/${{ matrix.ci_test_app }}:${{ github.sha }} + outputs: type=docker,dest=/tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar + - name: Upload built image artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.ci_test_app }}-image + path: /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar test: needs: build @@ -62,8 +80,34 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Fake Run - run: echo "<?xml version='1.0'?><testsuites><testsuite name='rspec' tests='1735' failures='0'/></testsuites>" >> rspec.xml + - name: Setup tmate debug session + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} + with: + limit-access-to-actor: true + detached: true + - name: Download built image artifact + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.ci_test_app }}-image + path: /tmp + - name: Start containers + run: | + docker load --input /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar + docker image ls -a + docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml up -d --quiet-pull --pull missing --no-build + - name: RSpec + env: + CI_NODE_TOTAL: ${{ matrix.ci_node_total }} + CI_NODE_INDEX: ${{ matrix.ci_node_index }} + run: >- + docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml exec -T -w /app/samvera/hyrax-engine web sh -c + "bundle install && yarn install && rspec_booster --job ${{ matrix.ci_node_index }}/${{ matrix.ci_node_total }}" + - name: Capture Container Logs + if: always() + uses: jwalton/gh-docker-logs@v2 + with: + images: 'seleniarm/standalone-chromium' - name: Move Test Files if: always() env: @@ -72,7 +116,7 @@ jobs: CI_NODE_INDEX: ${{ matrix.ci_node_index }} run: >- mv rspec.xml rspec-${CI_TEST_APP}-${CI_NODE_INDEX}.xml - - name: Archive spec reports (${{ matrix.ci_node_index}}) + - name: Archive spec reports uses: actions/upload-artifact@v4 if: always() with: From 4d61d48b45ae52b53476195f6091debf25ed01e3 Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Fri, 9 Aug 2024 16:21:47 -0700 Subject: [PATCH 19/22] Add configuration for config_search_paths This commit will allow gems to override the SimpleSchemaLoader#config_search_paths easily. --- app/services/hyrax/simple_schema_loader.rb | 2 +- lib/hyrax/configuration.rb | 18 ++++++++++++++++++ spec/lib/hyrax/configuration_spec.rb | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/services/hyrax/simple_schema_loader.rb b/app/services/hyrax/simple_schema_loader.rb index 7fb373e607..f87969e942 100644 --- a/app/services/hyrax/simple_schema_loader.rb +++ b/app/services/hyrax/simple_schema_loader.rb @@ -158,7 +158,7 @@ def config_paths(schema_name) end def config_search_paths - [Rails.root, Hyrax::Engine.root] + Hyrax.config.simple_schema_loader_config_search_paths end def metadata_files diff --git a/lib/hyrax/configuration.rb b/lib/hyrax/configuration.rb index c3f25099a9..470873b192 100644 --- a/lib/hyrax/configuration.rb +++ b/lib/hyrax/configuration.rb @@ -1154,6 +1154,24 @@ def visibility_map @visibility_map ||= Hyrax::VisibilityMap.instance end + attr_writer :simple_schema_loader_config_search_paths + # A configuration for modifying the SimpleSchemaLoader#config_search_paths + # which will allow gems to add their own metadata yaml files and easily keep + # them within the gem. + # + # @return [Array<Pathname>] + # @see Hyrax::SimpleSchemaLoader#config_search_paths + # @example + # Hyrax.config do |config| + # config.simple_schema_loader_config_search_paths.unshift(HykuKnapsack::Engine.root) + # end + # + # Hyrax.config.simple_schema_loader_config_search_paths + # => [#<Pathname:/app/samvera>, #<Pathname:/app/samvera/hyrax-webapp>, #<Pathname:/app/samvera/hyrax-webapp/gems/hyrax>] + def simple_schema_loader_config_search_paths + @simple_schema_loader_config_search_paths ||= [Rails.root, Hyrax::Engine.root] + end + private # @param [Symbol, #to_s] model_name - symbol representing the model diff --git a/spec/lib/hyrax/configuration_spec.rb b/spec/lib/hyrax/configuration_spec.rb index b8591e3d95..525fe69814 100644 --- a/spec/lib/hyrax/configuration_spec.rb +++ b/spec/lib/hyrax/configuration_spec.rb @@ -115,6 +115,7 @@ it { is_expected.to respond_to(:range_for_number_of_results_to_display_per_page) } it { is_expected.to respond_to(:range_for_number_of_results_to_display_per_page=) } it { is_expected.to respond_to(:work_requires_files?) } + it { is_expected.to respond_to(:simple_schema_loader_config_search_paths) } describe "#registered_ingest_dirs" do it "provides the Rails tmp directory for temporary downloads for cloud files" do From fa67bc91b494940eaf6def7321fd56096860056b Mon Sep 17 00:00:00 2001 From: Rob Kaufman <rob@notch8.com> Date: Tue, 13 Aug 2024 10:53:26 -0700 Subject: [PATCH 20/22] fix ga4 stats not being able to retrieve events properly, add work show to user vitals (#6886) --- app/assets/javascripts/hyrax/analytics_events.js | 2 +- app/services/hyrax/analytics/ga4.rb | 10 +--------- app/services/hyrax/analytics/ga4/base.rb | 10 ++++++++++ app/services/hyrax/analytics/ga4/events.rb | 4 ---- app/services/hyrax/analytics/ga4/events_daily.rb | 4 ---- app/services/hyrax/analytics/ga4/visits.rb | 4 ---- app/services/hyrax/analytics/ga4/visits_daily.rb | 4 ---- app/views/hyrax/users/_vitals.html.erb | 5 +++-- config/locales/hyrax.en.yml | 5 +++-- 9 files changed, 18 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/hyrax/analytics_events.js b/app/assets/javascripts/hyrax/analytics_events.js index b73d4a5463..c4f1b22364 100644 --- a/app/assets/javascripts/hyrax/analytics_events.js +++ b/app/assets/javascripts/hyrax/analytics_events.js @@ -49,7 +49,7 @@ function trackAnalyticsEvents(provider) { if(provider !== 'ga4') { window.trackingTags.analytics().push([window.trackingTags.trackEvent(), eventSpan.data('category'), eventSpan.data('action'), eventSpan.data('name')]); } else { - gtag('event', eventspan.data('action'), { 'content_type': eventspan.data('category'), 'content_id': eventspan.data('name')}) + gtag('event', eventSpan.data('action'), { 'content_type': eventSpan.data('category'), 'content_id': eventSpan.data('name')}) } }) } diff --git a/app/services/hyrax/analytics/ga4.rb b/app/services/hyrax/analytics/ga4.rb index fe162e1a7e..6d1553645e 100644 --- a/app/services/hyrax/analytics/ga4.rb +++ b/app/services/hyrax/analytics/ga4.rb @@ -15,14 +15,6 @@ module Ga4 extend ActiveSupport::Concern # rubocop:disable Metrics/BlockLength class_methods do - def client - @client - end - - def client=(value) - @client = value - end - # Loads configuration options from config/analytics.yml. You only need PRIVATE_KEY_PATH or # PRIVATE_KEY_VALUE. VALUE takes precedence. # Expected structure: @@ -87,7 +79,7 @@ def account_info end def client - self.class.client ||= ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new do |conf| + @client ||= ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new do |conf| conf.credentials = config.account_info end end diff --git a/app/services/hyrax/analytics/ga4/base.rb b/app/services/hyrax/analytics/ga4/base.rb index 0cc1bbfb79..d9ac0fe718 100644 --- a/app/services/hyrax/analytics/ga4/base.rb +++ b/app/services/hyrax/analytics/ga4/base.rb @@ -5,6 +5,16 @@ module Ga4 class Base attr_reader :start_date, :end_date, :dimensions, :metrics + def initialize(start_date:, + end_date:, + dimensions: [], + metrics: []) + @start_date = start_date.to_date + @end_date = end_date.to_date + @dimensions = dimensions + @metrics = metrics + end + def filters @filters ||= {} end diff --git a/app/services/hyrax/analytics/ga4/events.rb b/app/services/hyrax/analytics/ga4/events.rb index 7453ed0941..c16ca55e33 100644 --- a/app/services/hyrax/analytics/ga4/events.rb +++ b/app/services/hyrax/analytics/ga4/events.rb @@ -8,10 +8,6 @@ def initialize(start_date:, dimensions: [{ name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }], metrics: [{ name: 'eventCount' }]) super - @start_date = start_date.to_date - @end_date = end_date.to_date - @dimensions = dimensions - @metrics = metrics end def self.list(start_date, end_date, action) diff --git a/app/services/hyrax/analytics/ga4/events_daily.rb b/app/services/hyrax/analytics/ga4/events_daily.rb index 91da94555a..0bc82b029b 100644 --- a/app/services/hyrax/analytics/ga4/events_daily.rb +++ b/app/services/hyrax/analytics/ga4/events_daily.rb @@ -8,10 +8,6 @@ def initialize(start_date:, dimensions: [{ name: 'date' }, { name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }], metrics: [{ name: 'eventCount' }]) super - @start_date = start_date.to_date - @end_date = end_date.to_date - @dimensions = dimensions - @metrics = metrics end # returns a daily number of events for a specific action diff --git a/app/services/hyrax/analytics/ga4/visits.rb b/app/services/hyrax/analytics/ga4/visits.rb index 9479ef96c6..090f4e766a 100644 --- a/app/services/hyrax/analytics/ga4/visits.rb +++ b/app/services/hyrax/analytics/ga4/visits.rb @@ -5,10 +5,6 @@ module Ga4 class Visits < Hyrax::Analytics::Ga4::Base def initialize(start_date:, end_date:, dimensions: [{ name: 'newVsReturning' }], metrics: [{ name: 'sessions' }]) super - @start_date = start_date.to_date - @end_date = end_date.to_date - @dimensions = dimensions - @metrics = metrics end def new_visits diff --git a/app/services/hyrax/analytics/ga4/visits_daily.rb b/app/services/hyrax/analytics/ga4/visits_daily.rb index 2194eff7d7..cb4ee5400a 100644 --- a/app/services/hyrax/analytics/ga4/visits_daily.rb +++ b/app/services/hyrax/analytics/ga4/visits_daily.rb @@ -5,10 +5,6 @@ module Ga4 class VisitsDaily < Hyrax::Analytics::Ga4::Base def initialize(start_date:, end_date:, dimensions: [{ name: 'date' }, { name: 'newVsReturning' }], metrics: [{ name: 'sessions' }]) super - @start_date = start_date.to_date - @end_date = end_date.to_date - @dimensions = dimensions - @metrics = metrics end def new_visits diff --git a/app/views/hyrax/users/_vitals.html.erb b/app/views/hyrax/users/_vitals.html.erb index 755ef9a03f..eaf733d458 100644 --- a/app/views/hyrax/users/_vitals.html.erb +++ b/app/views/hyrax/users/_vitals.html.erb @@ -12,7 +12,8 @@ <span class="fa fa-upload" aria-hidden="true"></span> <%= link_to_works(user) %> <ul class="views-downloads-dashboard list-unstyled"> - <li><span class="badge badge-optional dark-text"><%= user.total_file_views %></span> <%= t("hyrax.dashboard.stats.file_views").pluralize(user.total_file_views) %></li> - <li><span class="badge badge-optional dark-text"><%= user.total_file_downloads %></span> <%= t("hyrax.dashboard.stats.file_downloads").pluralize(user.total_file_downloads) %></li> + <li><span class="badge badge-optional dark-text"><%= user.total_work_views %></span> <%= t("hyrax.dashboard.stats.work_views").pluralize(user.total_work_views) %></li> + <li><span class="badge badge-optional dark-text"><%= user.total_file_views %></span> <%= t("hyrax.dashboard.stats.file_views").pluralize(user.total_file_views) %></li> + <li><span class="badge badge-optional dark-text"><%= user.total_file_downloads %></span> <%= t("hyrax.dashboard.stats.file_downloads").pluralize(user.total_file_downloads) %></li> </ul> </div> diff --git a/config/locales/hyrax.en.yml b/config/locales/hyrax.en.yml index d66dc7174d..709b0118ab 100644 --- a/config/locales/hyrax.en.yml +++ b/config/locales/hyrax.en.yml @@ -1141,8 +1141,9 @@ en: graph_reports: Customized Graph Reports stats: collections: Collections created - file_downloads: Download - file_views: View + work_views: Metadata View + file_downloads: File Download + file_views: File View files: Files deposited heading: Your Statistics joined_on: Joined on From 69f0b81ff7bdbe5dff9620306ee542668ac86425 Mon Sep 17 00:00:00 2001 From: Rob Kaufman <rob@notch8.com> Date: Thu, 15 Aug 2024 09:09:18 -0700 Subject: [PATCH 21/22] allow base64 encoding of ga4 user env, fix user stat collection nil bug (#6889) --- app/services/hyrax/analytics/ga4.rb | 11 ++++++++++- app/services/hyrax/user_stat_importer.rb | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/services/hyrax/analytics/ga4.rb b/app/services/hyrax/analytics/ga4.rb index 6d1553645e..4dcb83f89d 100644 --- a/app/services/hyrax/analytics/ga4.rb +++ b/app/services/hyrax/analytics/ga4.rb @@ -62,8 +62,17 @@ def valid? REQUIRED_KEYS.all? { |required| @config[required].present? } end + def base64?(value) + value.is_a?(String) && Base64.strict_encode64(Base64.decode64(value)) == value + end + def account_json_string - @account_json ||= @config['account_json'] || File.read(@config['account_json_path']) + return @account_json_string if @account_json_string + @account_json_string = if @config['account_json'] + base64?(@config['account_json']) ? Base64.decode64(@config['account_json']) : @config['account_json'] + else + File.read(@config['account_json_path']) + end end def account_info diff --git a/app/services/hyrax/user_stat_importer.rb b/app/services/hyrax/user_stat_importer.rb index c99b9a3494..d22e72d7af 100644 --- a/app/services/hyrax/user_stat_importer.rb +++ b/app/services/hyrax/user_stat_importer.rb @@ -124,7 +124,7 @@ def tally_results(current_stats, stat_name, total_stats) date_key = stats.date.to_s old_count = total_stats[date_key] ? total_stats[date_key].fetch(stat_name) { 0 } : 0 - new_count = old_count + stats.method(stat_name).call + new_count = old_count + stats.method(stat_name).call.to_i old_values = total_stats[date_key] || {} total_stats.store(date_key, old_values) From e9e360f109b7086cc2732b9f640534ff841eac9a Mon Sep 17 00:00:00 2001 From: Kirk Wang <kirk.wang@scientist.com> Date: Fri, 16 Aug 2024 12:30:57 -0700 Subject: [PATCH 22/22] Fix subtle background gradient on featured works The gradient was throwing an invalid property value error which should be fixed now. --- app/assets/stylesheets/hyrax/_nestable.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/hyrax/_nestable.scss b/app/assets/stylesheets/hyrax/_nestable.scss index 82b5873dfe..099d1d2053 100644 --- a/app/assets/stylesheets/hyrax/_nestable.scss +++ b/app/assets/stylesheets/hyrax/_nestable.scss @@ -82,7 +82,7 @@ tr.dd-item { background: #fafafa; background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%); background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%); - background: linear-gradient(top, #fafafa 0%, #eee 100%); + background: linear-gradient(to bottom, #fafafa 0%, #eee 100%); -webkit-border-radius: 3px; border-radius: 3px; box-sizing: border-box; -moz-box-sizing: border-box;