debian-mirror-gitlab/app/helpers/numbers_helper.rb
2018-12-05 23:21:45 +05:30

15 lines
438 B
Ruby

# frozen_string_literal: true
module NumbersHelper
# rubocop: disable CodeReuse/ActiveRecord
def limited_counter_with_delimiter(resource, **options)
limit = options.fetch(:limit, 1000).to_i
count = resource.limit(limit + 1).count(:all)
if count > limit
number_with_delimiter(count - 1, options) + '+'
else
number_with_delimiter(count, options)
end
end
# rubocop: enable CodeReuse/ActiveRecord
end