<commit_before>var psi = require('psi');
var MongoClient = require('mongodb').MongoClient;
var assert = require('assert');
var mongoUrl;

if (process.env.OPENSHIFT_MONGODB_DB_URL) {
    mongoUrl = process.env.OPENSHIFT_MONGODB_DB_URL + 'pagespeed';
} else {
    mongoUrl = 'mongodb://localhost:27017/pagespeed';
}

var insertDocument = function (data, db, callback) {
    db.collection('results').insertOne(data, function (err, result) {
        assert.equal(err, null);
        console.log('Inserted a document into the results collection.');
        callback(result);
    });
};

psi('http://access.redhat.com', {
    key: process.env.PS_API_KEY || '<KEY>',
    strategy: 'mobile'
}).then(function (data) {
    MongoClient.connect(mongoUrl, function (err, db) {
        assert.equal(null, err);
        insertDocument(data, db, function () {
            db.close();<commit_msg>added console message to pagespeed script<commit_after>var psi = require('psi');
var MongoClient = require('mongodb').MongoClient;
var assert = require('assert');
var mongoUrl;

console.log('Pagespeed script is working!');

if (process.env.OPENSHIFT_MONGODB_DB_URL) {
    mongoUrl = process.env.OPENSHIFT_MONGODB_DB_URL + 'pagespeed';
} else {
    mongoUrl = 'mongodb://localhost:27017/pagespeed';
}

var insertDocument = function (data, db, callback) {
    db.collection('results').insertOne(data, function (err, result) {
        assert.equal(err, null);
        console.log('Inserted a document into the results collection.');
        callback(result);
    });
};

psi('http://access.redhat.com', {
    key: process.env.PS_API_KEY || '<KEY>',
    strategy: 'mobile'
}).then(function (data) {
    MongoClient.connect(mongoUrl, function (err, db) {
        assert.equal(null, err);
        insertDocument(data, db, function () {
            db.close();
{'fraction_non_alphanumeric': 0.15338427947598254, 'fraction_numerical': 0.0054585152838427945, 'mean_word_length': 3.8492063492063493, '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': '4757022', 'n_tokens_mistral': 592, 'n_tokens_neox': 591, 'n_words': 122}