<commit_before>'use strict';

const http = require('http')
const createHandler = require('github-webhook-handler')
const handler = createHandler({ path: '/webhook', secret: 'myhashsecret' })
const r = require('rethinkdb');
let connection = null;

r.connect({
    db: 'popcubex'
}, function(err, conn) {
    console.log(`[${new Date()}] Started database`);
    connection = conn;
});

http.createServer((req, res) => {
  handler(req, res, (err) => {
    res.statusCode = 404
    res.end('no such location')
  })
}).listen(7777);

console.log(`[${new Date()}] Started Webhook server`);

handler.on('error', (err) => {
  console.error('Error:', err.message)
});

handler.on('pull_request', (event) => {
  let pr = event.payload

  switch (pr.action) {
    case 'opened':
      r.table('pull_requests').insert(pr).run(conn, afterInsert);
      break;
    case 'closed':

      break;
    default:
      // do nothing
      break;<commit_msg>changes<commit_after>'use strict';

const http = require('http')
const createHandler = require('github-webhook-handler')
const handler = createHandler({ path: '/webhook', secret: 'myhashsecret' })
const r = require('rethinkdb');
let connection = null;

r.connect({
    db: 'popcubex'
}, function(err, conn) {
    console.log(`[${new Date()}] Started database`);
    connection = conn;
});

http.createServer((req, res) => {
  handler(req, res, (err) => {
    res.statusCode = 404
    res.end('no such location')
  })
}).listen(7777);

console.log(`[${new Date()}] Started Webhook server`);

handler.on('error', (err) => {
  console.error('Error:', err.message)
});

handler.on('pull_request', (event) => {
  let pr = event.payload

  switch (pr.action) {
    case 'opened':
      r.table('pull_requests').insert(pr).run(connection, afterInsert);
      break;
    case 'closed':

      break;
    default:
      // do nothing
      break;
{'fraction_non_alphanumeric': 0.18676627534685167, 'fraction_numerical': 0.007470651013874066, 'mean_word_length': 3.79539641943734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4561993', 'n_tokens_mistral': 629, 'n_tokens_neox': 615, 'n_words': 141}