<commit_before>module.exports = {
    prepare_headers: function(job){
        return new Promise(function(resolve, reject){
            "habr" in job.response || (job.response.habr = {});
            job.response.habr.headers = {};

            job.response.habr.headers['Content-Type'] = 'text/html';
            job.response.habr.headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; //Дата в прошлом 
            job.response.habr.headers['Cache-Control'] = ' no-cache, must-revalidate'; // HTTP/1.1 
            job.response.habr.headers['Pragma'] = ' no-cache';

            resolve(job);
        });
    }
   ,parse_cookies: function(job){
        return new Promise(function(resolve, reject){
            job.request.cookies = {};
            job.request.headers.cookie ||
            
                job.request.headers.cookie.split(';')
                                          .map(cV => cV.split('='))
                                          .map(cV => cV.length == 2 ? cV : null)
                                          .forEach(cV => cV || (job.request.cookies[cV[0].trim()] = cV[1].trim()));
            resolve(job);
        });
    }
    ,start_session: function(job){
        return new Promise(function(resolve, reject){
            request.cookies = parseCookies(request); 
            if(!("id" in request.cookies && request.cookies.id.trim() != '')){
                resolve(job);
                return;
            }
            //тянем сессию
            var pg = require("pg");
            var config = require("./config");
            pg.connect(config.common.postgres, function (err, pgClient, done) {
	        if(err){
                    console.log(err);
                    reject();
    	            return;
	        }
                pgClient.query({
                    text: "SELECT * FROM users WHERE sid = $1;"
	           ,values: [job.request.cookies.id]
	        }, function(err, result){
                    done();
                    switch(true){
	                case err:
	                    console.log(err); //не надо тут ставить break!!!
                        case result.rows.length != 1:
                            reject();
                            return;<commit_msg>start<commit_after>"use strict";
module.exports = {
    prepare_headers: function(job){
        return new Promise(function(resolve, reject){
            "habr" in job.response || (job.response.habr = {});
            job.response.habr.headers = {};

            job.response.habr.headers['Content-Type'] = 'text/html';
            job.response.habr.headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; //Дата в прошлом 
            job.response.habr.headers['Cache-Control'] = ' no-cache, must-revalidate'; // HTTP/1.1 
            job.response.habr.headers['Pragma'] = ' no-cache';

            resolve(job);
        });
    }
   ,parse_cookies: function(job){
        return new Promise(function(resolve, reject){
            job.request.cookies = {};
            job.request.headers.cookie ||
            
                job.request.headers.cookie.split(';')
                                          .map(cV => cV.split('='))
                                          .map(cV => cV.length == 2 ? cV : null)
                                          .forEach(cV => cV || (job.request.cookies[cV[0].trim()] = cV[1].trim()));
            resolve(job);
        });
    }
    ,start_session: function(job){
        return new Promise(function(resolve, reject){
            request.cookies = parseCookies(request); 
            if(!("id" in request.cookies && request.cookies.id.trim() != '')){
                resolve(job);
                return;
            }
            //тянем сессию
            var pg = require("pg");
            var config = require("./config");
            pg.connect(config.common.postgres, function (err, pgClient, done) {
	        if(err){
                    console.log(err);
                    reject();
    	            return;
	        }
                pgClient.query({
                    text: "SELECT * FROM users WHERE sid = $1;"
	           ,values: [job.request.cookies.id]
	        }, function(err, result){
                    if(err){
                        console.log(err);
                        reject();
    	                return;
                    }
                    done();
                    switch(true){
	                case err:
	                    console.log(err); //не надо тут ставить break!!!
                        case result.rows.length != 1:
                            reject();
                            return;
{'fraction_non_alphanumeric': 0.13764044943820225, 'fraction_numerical': 0.008210890233362144, 'mean_word_length': 1.2558479532163742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4246274', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1200, 'n_words': 225}