<commit_before>class PayloadParser
  def initialize(payload, headers)
    @payload = payload
    @headers = headers
  end

  def action
    payload["action"]
  end

  def event_type
    headers["X-Github-Event"]
  end

  def body
    pull_request_or_issue_params["body"] || ""
  end

  def comment
    payload["comment"] || {}
  end

  def github_issue_id
    pull_request_or_issue_params["id"]
  end

  def params
    {
      github_issue_id: github_issue_id,
      github_url: github_url,
      repo_name: repo_name,
      repo_github_url: repo_github_url,
      title: title,
      user_name: user_name,
      user_github_url: user_github_url,
    }
  end

  protected

  attr_reader :headers, :payload

  private

  def pull_request_or_issue_params
    payload["pull_request"] || payload["issue"]
  end

  def github_url
    payload["pull_request"]["html_url"]
  end

  def repo_name
    payload["pull_request"]["head"]["repo"]["full_name"]
  end

  def repo_github_url
    payload["pull_request"]["head"]["repo"]["html_url"]
  end

  def title
    payload["pull_request"]["title"]
  end

  def user_name
    payload["pull_request"]["head"]["user"]["login"]
  end

  def user_github_url
    payload["pull_request"]["head"]["user"]["html_url"]
  end
end<commit_msg>Return an empty hash if no pull request or issue<commit_after>class PayloadParser
  def initialize(payload, headers)
    @payload = payload
    @headers = headers
  end

  def action
    payload["action"]
  end

  def event_type
    headers["X-Github-Event"]
  end

  def body
    pull_request_or_issue_params["body"] || ""
  end

  def comment
    payload["comment"] || {}
  end

  def github_issue_id
    pull_request_or_issue_params["id"]
  end

  def params
    {
      github_issue_id: github_issue_id,
      github_url: github_url,
      repo_name: repo_name,
      repo_github_url: repo_github_url,
      title: title,
      user_name: user_name,
      user_github_url: user_github_url,
    }
  end

  protected

  attr_reader :headers, :payload

  private

  def pull_request_or_issue_params
    payload["pull_request"] || payload["issue"] || {}
  end

  def github_url
    payload["pull_request"]["html_url"]
  end

  def repo_name
    payload["pull_request"]["head"]["repo"]["full_name"]
  end

  def repo_github_url
    payload["pull_request"]["head"]["repo"]["html_url"]
  end

  def title
    payload["pull_request"]["title"]
  end

  def user_name
    payload["pull_request"]["head"]["user"]["login"]
  end

  def user_github_url
    payload["pull_request"]["head"]["user"]["html_url"]
  end
end
{'fraction_non_alphanumeric': 0.11719053162592162, 'fraction_numerical': 0.0, 'mean_word_length': 3.5709219858156027, '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': '5424460', 'n_tokens_mistral': 874, 'n_tokens_neox': 885, 'n_words': 172}