diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index 22bfaafbc..218ec215a 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -105,13 +105,6 @@ def search_and_filter(user, search_params = '', selected_facets = {}, page: 1, s facet ff, exclude: active_facets[ff] end - # Hide records the urls of which are failing - if method_defined?(:link_monitor) - unless user&.is_admin? - without(:failing, true) - end - end - end end end diff --git a/app/views/search/common/_facet_sidebar.html.erb b/app/views/search/common/_facet_sidebar.html.erb index b1b466b78..72a7534ee 100644 --- a/app/views/search/common/_facet_sidebar.html.erb +++ b/app/views/search/common/_facet_sidebar.html.erb @@ -63,6 +63,11 @@ Variable that should be available count: '-', enable_text: t('sidebar.filter.values.show_disabled_events'), disable_text: t('sidebar.filter.values.hide_disabled_events') } %> + <%= render partial: 'search/common/facet_sidebar_boolean_filter', + locals: { facet_field: 'include_broken_links', + count: '-', + enable_text: t('sidebar.filter.values.show_broken_links', resource: resource_type.model_name.human.downcase.pluralize), + disable_text: t('sidebar.filter.values.hide_broken_links', resource: resource_type.model_name.human.downcase.pluralize) } %> <% elsif resource_type.name == 'Material' || resource_type.name == 'LearningPath' %> <% resource_name = resource_type.model_name.human.downcase.pluralize %> <% if resource_type.name == 'Material' %> @@ -71,6 +76,11 @@ Variable that should be available count: '-', enable_text: t('sidebar.filter.values.show_disabled', resource: resource_name), disable_text: t('sidebar.filter.values.hide_disabled', resource: resource_name) } %> + <%= render partial: 'search/common/facet_sidebar_boolean_filter', + locals: { facet_field: 'include_broken_links', + count: '-', + enable_text: t('sidebar.filter.values.show_broken_links', resource: resource_name), + disable_text: t('sidebar.filter.values.hide_broken_links', resource: resource_name) } %> <% end %> <%= render partial: 'search/common/facet_sidebar_boolean_filter', locals: { facet_field: 'include_archived', diff --git a/config/locales/en.yml b/config/locales/en.yml index 3fe74d161..0de61fb83 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -874,6 +874,8 @@ en: hide_disabled: 'Hide disabled %{resource}' show_archived: 'Show archived %{resource}' hide_archived: 'Hide archived %{resource}' + show_broken_links: 'Show %{resource} with broken links' + hide_broken_links: 'Hide %{resource} with broken links' show_cross_space: 'Show %{resource} from all spaces' hide_cross_space: 'Hide %{resource} from all spaces' hidden: diff --git a/lib/facets.rb b/lib/facets.rb index 57d1cfba4..686316428 100644 --- a/lib/facets.rb +++ b/lib/facets.rb @@ -9,6 +9,7 @@ module Facets start: ->(c) { c.name == 'Event' }, running_during: ->(c) { c.name == 'Event' }, include_hidden: ->(c) { c.method_defined?(:user_requires_approval?) }, + include_broken_links: ->(c) { c.method_defined?(:link_monitor) }, across_all_spaces: ->(c) { TeSS::Config.feature['spaces'] && c.reflect_on_association(:space) } }.with_indifferent_access.freeze @@ -32,7 +33,8 @@ module Facets nil end }, - include_hidden: ->(value) { value == 'true' } + include_hidden: ->(value) { value == 'true' }, + include_broken_links: ->(value) { value == 'true' } } class << self @@ -113,6 +115,10 @@ def include_hidden(scope, value, user) end end + def include_broken_links(scope, value, _) + sunspot_scoped(scope) { without(:failing, true) } unless value + end + def days_since_scrape(scope, days, _) sunspot_scoped(scope) { with(:last_scraped).less_than(days.to_i.days.ago) } if days.present? end diff --git a/public/api/definitions/tess.yml b/public/api/definitions/tess.yml index bb8a647f9..4abe2470b 100644 --- a/public/api/definitions/tess.yml +++ b/public/api/definitions/tess.yml @@ -190,6 +190,11 @@ paths: description: Include events that are disabled. schema: type: boolean + - name: include_broken_links + in: query + description: Include events that have broken links. + schema: + type: boolean - name: eligibility[] in: query description: Filter by who is eligible to attend the event. @@ -429,6 +434,11 @@ paths: description: Include materials that are disabled. schema: type: boolean + - name: include_broken_links + in: query + description: Include materials that have broken links. + schema: + type: boolean responses: 200: description: A collection of materials, and facets available to filter them.