<commit_before>var _ = require('underscore');
var log = require('../logger');

module.exports = (function() {

  /**
   * @param {Object} pulsar
   * @constructor
   */
  function PulsarREST(pulsar) {
    this.pulsar = pulsar;
  }

  /**
   * @param {Object} server
   */
  PulsarREST.prototype.installHandlers = function(server) {
    var self = this;

    server.post('/:app/:env', function createJob(req, res, next) {
      var params = _.extend({}, req.params, req.query, req.body);
      var wait = !!params.wait;
      log.debug('Job create', {params: params});
      self.pulsar.createJob(params.app, params.env, params.task, params.taskVariables, function(err, job) {
        if (err) {
          log.error('Job create failed', {params: params}, err);
          return next(err);
        }
        log.debug('Job create success', {params: params, job: job});
        var response = {
          id: job.id,
          url: req.protocol + '://' + req.hostname + '/web/?job=' + job.id
        };
        if (wait) {
          job.on('close', function() {
            response.data = job.getData();
            res.send(response);
            return next();
          });
          job.execute();
        } else {
          job.execute();
          res.send(response);
          return next();<commit_msg>Fix url of created of pulsar job.<commit_after>var _ = require('underscore');
var log = require('../logger');

module.exports = (function() {

  /**
   * @param {Object} pulsar
   * @constructor
   */
  function PulsarREST(pulsar) {
    this.pulsar = pulsar;
  }

  /**
   * @param {Object} server
   */
  PulsarREST.prototype.installHandlers = function(server) {
    var self = this;

    server.post('/:app/:env', function createJob(req, res, next) {
      var params = _.extend({}, req.params, req.query, req.body);
      var wait = !!params.wait;
      log.debug('Job create', {params: params});
      self.pulsar.createJob(params.app, params.env, params.task, params.taskVariables, function(err, job) {
        if (err) {
          log.error('Job create failed', {params: params}, err);
          return next(err);
        }
        log.debug('Job create success', {params: params, job: job});
        var response = {
          id: job.id,
          url: req.protocol + '://' + req.headers.host + '/web/?job=' + job.id
        };
        if (wait) {
          job.on('close', function() {
            response.data = job.getData();
            res.send(response);
            return next();
          });
          job.execute();
        } else {
          job.execute();
          res.send(response);
          return next();
{'fraction_non_alphanumeric': 0.1643939393939394, 'fraction_numerical': 0.0, 'mean_word_length': 2.0745052386495924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '464891', 'n_tokens_mistral': 812, 'n_tokens_neox': 802, 'n_words': 181}