<commit_before>class SafariPushNotificationSend
  include Sidekiq::Worker
  sidekiq_options retry: false, queue: :critical

  def perform(user_ids, entry_id)
    users = User.where(id: user_ids)
    tokens = Device.where(user_id: user_ids).safari.pluck(:user_id, :token)
    entry = Entry.find(entry_id)
    feed = entry.feed
    verifier = ActiveSupport::MessageVerifier.new(Feedbin::Application.config.secret_key_base)

    titles = subscription_titles(user_ids, feed)
    body = format_text(entry.title, 90)
    title = format_text(feed.title, 36)

    notifications = tokens.each_with_object([]) do |(user_id, token), array|
      title = titles[user_id] || title
      notification = build_notification(token, title, body, entry_id, user_id, verifier)
      notification = Grocer::SafariNotification.new(notification)
      array.push(notification)
    end

    puts notifications.inspect<commit_msg>Push testing.<commit_after># ENV['RAILS_ENV'] = 'production'; reload!; p = SafariPushNotificationSend.new; p.perform([2], 2)
class SafariPushNotificationSend
  include Sidekiq::Worker
  sidekiq_options retry: false, queue: :critical

  def perform(user_ids, entry_id)
    users = User.where(id: user_ids)
    tokens = Device.where(user_id: user_ids).safari.pluck(:user_id, :token)
    entry = Entry.find(entry_id)
    feed = entry.feed
    verifier = ActiveSupport::MessageVerifier.new(Feedbin::Application.config.secret_key_base)

    titles = subscription_titles(user_ids, feed)
    body = format_text(entry.title, 90)
    title = format_text(feed.title, 36)

    notifications = tokens.each_with_object([]) do |(user_id, token), array|
      title = titles[user_id] || title
      notification = build_notification(token, title, body, entry_id, user_id, verifier)
      notification = Grocer::SafariNotification.new(notification)
      array.push(notification)
    end
{'fraction_non_alphanumeric': 0.11087420042643924, 'fraction_numerical': 0.005330490405117271, 'mean_word_length': 4.7051671732522795, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7381551', 'n_tokens_mistral': 609, 'n_tokens_neox': 588, 'n_words': 118}