<commit_before>/*
    (c) 2015 <NAME>. All rights reserved.
*/

var config = require("./config.js");
var io, socket_end_point;
var extensions = require("./modules/extensions/index.js");
var fs = require("fs");

var express = require("express");
var app = express();
var http = require("http").Server(app);
var sha1 = require("sha1");
var request = require("request");
var cheerio = require('cheerio');

if (config.production) {
    io = require("socket.io")(http, {
        path: '/socket.io'
    });
    config.socket = {
        path: '/codevisor/socket.io'
    };
} else {
    io = require("socket.io")(http);
    config.socket = {};
}

var mongoose = require("mongoose");

var ObjectId = require('mongoose').Types.ObjectId;

// Schema

var pageSchema = mongoose.Schema({
    owner: String, // owner of repository
    repo: String, // repository
    head: String, // branch
    styles: Object, // page styles
    tree: Object, // cache of tree 
    commits: Object, // cache of commits
    contributors: Object, // cache of contributors
    sockets: Array // currently connected sockets and their preferences
});

var Page = mongoose.model("page", pageSchema);

mongoose.connect('mongodb://localhost:27017/codevisor');
var db = mongoose.connection;
db.on('error', function(callback) {
    console.log("[CodeVisor] Error Connecting to MongoDB");
});
db.once('open', function(callback) {
    console.log("[CodeVisor] Connected to MongoDB");
});

app.use("/", express.static(__dirname + "/static"));

app.get("/get_config", function(req, res) {
    res.json(config);
});

app.post("/hooks", function(req, res) {
    var data = req.body;
    Page.findOne({
        owner: data.organization.login.toLowerCase(),
        repo: data.repository.name.toLowerCase()
    }, function(err, page) {
        if (err) console.log(err);

        if (page) {<commit_msg>JSON.parse() payload<commit_after>/*
    (c) 2015 <NAME>. All rights reserved.
*/

var config = require("./config.js");
var io, socket_end_point;
var extensions = require("./modules/extensions/index.js");
var fs = require("fs");

var express = require("express");
var app = express();
var http = require("http").Server(app);
var sha1 = require("sha1");
var request = require("request");
var cheerio = require('cheerio');

if (config.production) {
    io = require("socket.io")(http, {
        path: '/socket.io'
    });
    config.socket = {
        path: '/codevisor/socket.io'
    };
} else {
    io = require("socket.io")(http);
    config.socket = {};
}

var mongoose = require("mongoose");

var ObjectId = require('mongoose').Types.ObjectId;

// Schema

var pageSchema = mongoose.Schema({
    owner: String, // owner of repository
    repo: String, // repository
    head: String, // branch
    styles: Object, // page styles
    tree: Object, // cache of tree 
    commits: Object, // cache of commits
    contributors: Object, // cache of contributors
    sockets: Array // currently connected sockets and their preferences
});

var Page = mongoose.model("page", pageSchema);

mongoose.connect('mongodb://localhost:27017/codevisor');
var db = mongoose.connection;
db.on('error', function(callback) {
    console.log("[CodeVisor] Error Connecting to MongoDB");
});
db.once('open', function(callback) {
    console.log("[CodeVisor] Connected to MongoDB");
});

app.use("/", express.static(__dirname + "/static"));

app.get("/get_config", function(req, res) {
    res.json(config);
});

app.post("/hooks", function(req, res) {
    var data = req.body;
    var data = JSON.parse(req.body);
    Page.findOne({
        owner: data.organization.login.toLowerCase(),
        repo: data.repository.name.toLowerCase()
    }, function(err, page) {
        if (err) console.log(err);

        if (page) {
{'fraction_non_alphanumeric': 0.17128396377197655, 'fraction_numerical': 0.005860415556739478, 'mean_word_length': 3.497005988023952, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2284022', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1169, 'n_words': 292}