Merge pull request #4201 from AntonKhorev/issues-limit-settings

Move max value of issues counter to settings
This commit is contained in:
Andy Allan 2023-09-27 15:47:44 +01:00 committed by GitHub
commit 0a046673d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 3 deletions

View file

@ -26,9 +26,9 @@ module IssuesHelper
end end
def open_issues_count def open_issues_count
count = Issue.visible_to(current_user).open.limit(100).size count = Issue.visible_to(current_user).open.limit(Settings.max_issues_count).size
if count > 99 if count >= Settings.max_issues_count
tag.span("99+", :class => "badge count-number") tag.span(I18n.t("count.at_least_pattern", :count => Settings.max_issues_count), :class => "badge count-number")
elsif count.positive? elsif count.positive?
tag.span(count, :class => "badge count-number") tag.span(count, :class => "badge count-number")
end end

View file

@ -77,6 +77,7 @@ Config.setup do |config|
required(:tracepoints_per_page).filled(:int?) required(:tracepoints_per_page).filled(:int?)
required(:max_number_of_way_nodes).filled(:int?) required(:max_number_of_way_nodes).filled(:int?)
required(:max_number_of_relation_members).filled(:int?) required(:max_number_of_relation_members).filled(:int?)
required(:max_issues_count).filled(:int?)
required(:api_timeout).filled(:int?) required(:api_timeout).filled(:int?)
required(:imagery_blacklist).maybe(:array?) required(:imagery_blacklist).maybe(:array?)
required(:status).filled(:str?, :included_in? => ALLOWED_STATUS) required(:status).filled(:str?, :included_in? => ALLOWED_STATUS)

View file

@ -5,6 +5,8 @@ en:
formats: formats:
friendly: "%e %B %Y at %H:%M" friendly: "%e %B %Y at %H:%M"
blog: "%e %B %Y" blog: "%e %B %Y"
count:
at_least_pattern: "%{count}+"
helpers: helpers:
file: file:
prompt: Choose file prompt: Choose file

View file

@ -43,6 +43,8 @@ max_note_request_area: 25
default_note_query_limit: 100 default_note_query_limit: 100
# Maximum limit on the number of notes returned by the note search api method # Maximum limit on the number of notes returned by the note search api method
max_note_query_limit: 10000 max_note_query_limit: 10000
# Maximum value of open issues counter for moderators, anything equal or greater to this value "n" is shown as "n+"
max_issues_count: 99
# Zoom level to use for postcode results from the geocoder # Zoom level to use for postcode results from the geocoder
postcode_zoom: 15 postcode_zoom: 15
# Timeout for API calls in seconds # Timeout for API calls in seconds

View file

@ -0,0 +1,30 @@
require "test_helper"
class IssuesHelperTest < ActionView::TestCase
attr_accessor :current_user
def test_issues_count
target_user = create(:user)
self.current_user = create(:moderator_user)
n = (Settings.max_issues_count - 1)
n.times do
create(:note_with_comments) do |note|
create(:issue, :reportable => note, :reported_user => target_user, :assigned_role => "moderator")
end
end
expected = <<~HTML.delete("\n")
<span class="badge count-number">#{n}</span>
HTML
assert_dom_equal expected, open_issues_count
n += 1
create(:note_with_comments) do |note|
create(:issue, :reportable => note, :reported_user => target_user, :assigned_role => "moderator")
end
expected = <<~HTML.delete("\n")
<span class="badge count-number">#{n}+</span>
HTML
assert_dom_equal expected, open_issues_count
end
end