<commit_before>module Payloads
  class GithubHooksController < ActionController::Base
    before_filter :check_if_push_event

    expose(:parser) { GithubHookParser::Main.new params[:payload] }

    def create
      ProjectFromRepositoryParser.new(parser.repository).find_or_create
      CommitsFromCommitParsers.new(parser.commits).create
      render text: 'ok'
    end

    private

    def check_if_push_event
      render text: 'ignored' if github_event_type != 'push'
    end

    def github_event_type
      request.headers.fetch('X-GitHub-Event')
    end
  end
end<commit_msg>Properly handle json data from POST request<commit_after>module Payloads
  class GithubHooksController < ActionController::Base
    before_filter :check_if_push_event

    expose(:parser) { GithubHookParser::Main.new request.raw_post }

    def create
      ProjectFromRepositoryParser.new(parser.repository).find_or_create
      CommitsFromCommitParsers.new(parser.commits).create
      render text: 'ok'
    end

    private

    def check_if_push_event
      render text: 'ignored' if github_event_type != 'push'
    end

    def github_event_type
      request.headers.fetch('X-GitHub-Event')
    end
  end
end
{'fraction_non_alphanumeric': 0.07512520868113523, 'fraction_numerical': 0.0, 'mean_word_length': 3.720472440944882, 'pattern_counts': {'":': 0, '<': 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': '7481570', 'n_tokens_mistral': 373, 'n_tokens_neox': 361, 'n_words': 73}