summaryrefslogtreecommitdiff
path: root/app/helpers/numbers_helper.rb
blob: f609b6c0cec929e5248c9befdb0c9dfb52341047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# frozen_string_literal: true

module NumbersHelper
  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
end