<commit_before>class SlackPingerJob < ActiveJob::Base
  queue_as :default

  def perform(booking_request)
    return unless hook_uri

    booking_location = BookingLocations.find(booking_request.location_id)
    actual_location  = booking_location.name_for(booking_request.location_id)

    hook = WebHook.new(hook_uri)
    hook.call(payload(actual_location, booking_request.slots.size))
  end

  private

  def hook_uri
    ENV['BOOKING_REQUESTS_SLACK_PINGER_URI']
  end

  def payload(actual_location, slot_count)
    {
      username: 'frank',
      channel: '#online-bookings',
      text: ":rotating_light: #{actual_location} (#{slot_count} slots) :rotating_light:",
      icon_emoji: ':frank:'
    }
  end
end<commit_msg>Pluralize slot count for slack pinger<commit_after>class SlackPingerJob < ActiveJob::Base
  include ActionView::Helpers::TextHelper

  queue_as :default

  def perform(booking_request)
    return unless hook_uri

    booking_location = BookingLocations.find(booking_request.location_id)
    actual_location  = booking_location.name_for(booking_request.location_id)

    hook = WebHook.new(hook_uri)
    hook.call(payload(actual_location, booking_request.slots.size))
  end

  private

  def hook_uri
    ENV['BOOKING_REQUESTS_SLACK_PINGER_URI']
  end

  def payload(actual_location, slot_count)
    slot_count = pluralize(slot_count, 'slot')

    {
      username: 'frank',
      channel: '#online-bookings',
      text: ":rotating_light: #{actual_location} (#{slot_count}) :rotating_light:",
      icon_emoji: ':frank:'
    }
  end
end
{'fraction_non_alphanumeric': 0.09724888035828536, 'fraction_numerical': 0.0, 'mean_word_length': 4.449477351916376, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1435230', 'n_tokens_mistral': 532, 'n_tokens_neox': 513, 'n_words': 90}