<commit_before>var _ = require('underscore'),
  log = require('../logger'),
  Query = require('../querist'),
  appConfig = require('../../config');


function Stagecraft(options) {

  var defaults = {
    baseUrl : 'https://stagecraft.production.performance.service.gov.uk/',
    auth: {
      bearer: appConfig.stagecraft.bearer
    }
  };

  this.config = _.extend({}, defaults, options);

}

Stagecraft.prototype.queryEmail = function (dataSet) {

  var client = new Query({
    baseUrl: this.config.baseUrl
  });

  return client.get('data-sets/' + dataSet.name + '/users', this.config)
    .then( function (data) {
      if (data.length) {
        log.info('Found', dataSet.emails, 'for', dataSet.name);
        dataSet.emails = _.pluck(data, 'email');
      } else {
        log.warn('No emails found for ' + dataSet.name);
        dataSet['emails'] = appConfig.notificationsEmail;
      }
      return dataSet;
    });

};<commit_msg>Change ordering of log messaging in stagecraft integration<commit_after>var _ = require('underscore'),
  log = require('../logger'),
  Query = require('../querist'),
  appConfig = require('../../config');


function Stagecraft(options) {

  var defaults = {
    baseUrl : 'https://stagecraft.production.performance.service.gov.uk/',
    auth: {
      bearer: appConfig.stagecraft.bearer
    }
  };

  this.config = _.extend({}, defaults, options);

}

Stagecraft.prototype.queryEmail = function (dataSet) {

  var client = new Query({
    baseUrl: this.config.baseUrl
  });

  return client.get('data-sets/' + dataSet.name + '/users', this.config)
    .then( function (data) {
      if (data.length) {
        dataSet.emails = _.pluck(data, 'email');
        log.info('Found', dataSet.emails, 'for', dataSet.name);
      } else {
        log.warn('No emails found for ' + dataSet.name);
        dataSet['emails'] = appConfig.notificationsEmail;
      }
      return dataSet;
    });

};
{'fraction_non_alphanumeric': 0.16709911779968864, 'fraction_numerical': 0.0, 'mean_word_length': 2.8870967741935485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6588291', 'n_tokens_mistral': 616, 'n_tokens_neox': 600, 'n_words': 121}