Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions app/models/concerns/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions app/views/search/common/_facet_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' %>
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion lib/facets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions public/api/definitions/tess.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading