<commit_before>require 'net/http'

class StagingSyncWorker
  include Sidekiq::Worker

  def perform(user_id)
    user = User.find(user_id)
    payload = {
      password_digest: <PASSWORD>,
      name: user.name,
      id: user.id,
      email: user.email,
      pro_expires_at: user.pro_expires_at
    }
    conn = Faraday::Connection.new('https://staging.kitsu.io/api/user/_prodsync')
    conn.basic_auth('Production', ENV['DISCOURSE_SSO_SECRET'])
    conn.post(payload)
  end
end<commit_msg>Raise an exception if the staging sync responds with non-200<commit_after>require 'net/http'

class StagingSyncWorker
  include Sidekiq::Worker

  def perform(user_id)
    user = User.find(user_id)
    payload = {
      password_digest: <PASSWORD>,
      name: user.name,
      id: user.id,
      email: user.email,
      pro_expires_at: user.pro_expires_at
    }
    conn = Faraday::Connection.new('https://staging.kitsu.io/api/user/_prodsync')
    conn.basic_auth('Production', ENV['DISCOURSE_SSO_SECRET'])
    conn.post(payload)
    raise "Bad response: #{conn.body}" if conn.status != 200
  end
end
{'fraction_non_alphanumeric': 0.12135036496350365, 'fraction_numerical': 0.005474452554744526, 'mean_word_length': 3.477551020408163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1537500', 'n_tokens_mistral': 400, 'n_tokens_neox': 382, 'n_words': 71}