<commit_before>/* jslint node: true */
var sql = require('mssql');

// config for DB connections
var dbConfig = require('config').Database;
var dbConfigAccount = require('config').DatabaseAccounts;
var config = {
  user: dbConfig.user,
  password: <PASSWORD>,
  server: dbConfig.server,
  database: dbConfig.database
};
var configAccount = {
  user: dbConfigAccount.user,
  password: <PASSWORD>,
  server: dbConfigAccount.server,
  database: dbConfigAccount.database
};

exports.getReports = function(insights) {
  'use strict';

  // get where clause - using config file for the time being
  var dbWhere = 'where LogEntryId > ' + dbConfig.lastProcessed;
  var conn = new sql.Connection(config, function (err) {
    // check for error
    if (err) {
      console.error(err.stack);
    } else {
      console.info('Gathering reports run since LogEntryId: ' + dbConfig.lastProcessed);

      // get the data
      var request = new sql.Request(conn);
      request.query('SELECT TOP 100 \'' + dbConfig.appName + '\' AS appName, * FROM dbo.InsightsExecutionLog ' + dbWhere, function (err, recordset) {
        // check for error
        if (err) {
          console.error(err.stack);
        } else {
          if (recordset.length > 0) {
            console.info('Processing ' + recordset.length + ' SSRS report executions');
            dbConfig.lastProcessed = recordset[recordset.length - 1].LogEntryId;
            getAccount(recordset, function(data){
              console.log(data[0].user + ' - ' + data[0].account);
              insights.send(data);
            });
          }
        }
      });
    }
  });
};
<commit_msg>Changed to use set method to assign value back in to config.<commit_after>/* jslint node: true */
var sql = require('mssql');

// config for DB connections
var dbConfig = require('config').Database;
var dbConfigAccount = require('config').DatabaseAccounts;
var config = {
  user: dbConfig.user,
  password: <PASSWORD>,
  server: dbConfig.server,
  database: dbConfig.database
};
var configAccount = {
  user: dbConfigAccount.user,
  password: <PASSWORD>,
  server: dbConfigAccount.server,
  database: dbConfigAccount.database
};

exports.getReports = function(insights) {
  'use strict';

  // get where clause - using config file for the time being
  var dbWhere = 'where LogEntryId > ' + dbConfig.lastProcessed;
  var conn = new sql.Connection(config, function (err) {
    // check for error
    if (err) {
      console.error(err.stack);
    } else {
      console.info('Gathering reports run since LogEntryId: ' + dbConfig.lastProcessed);

      // get the data
      var request = new sql.Request(conn);
      request.query('SELECT TOP 100 \'' + dbConfig.appName + '\' AS appName, * FROM dbo.InsightsExecutionLog ' + dbWhere, function (err, recordset) {
        // check for error
        if (err) {
          console.error(err.stack);
        } else {
          if (recordset.length > 0) {
            console.info('Processing ' + recordset.length + ' SSRS report executions');
            dbConfig.lastProcessed.set(recordset[recordset.length - 1].LogEntryId);
            #dbConfig.lastProcessed = recordset[recordset.length - 1].LogEntryId;
            getAccount(recordset, function(data){
              console.log(data[0].user + ' - ' + data[0].account);
              insights.send(data);
            });
          }
        }
      });
    }
  });
};

{'fraction_non_alphanumeric': 0.12772218952324896, 'fraction_numerical': 0.0044143613890523835, 'mean_word_length': 2.674594594594595, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2294846', 'n_tokens_mistral': 1017, 'n_tokens_neox': 997, 'n_words': 247}