2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-26 07:42:04 -04:00
|
|
|
module NumbersHelper
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-09-26 07:42:04 -04:00
|
|
|
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
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-09-26 07:42:04 -04:00
|
|
|
end
|