<commit_before>var Initializer = require('./Initializer');
var _ = require('lodash');
var _super = Initializer.prototype;

module.exports = Initializer.extend({

  'generate': function () {

    var self = this;
    var started = new Date();
    var baseUrl = 'http://' + self.options.domain_name;
    var count = 0;
    var xml = '';

    xml += '<?xml version="1.0" encoding="utf-8"?>';
    xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

    self.options.pages.each(function (page) {

      if (!page.isHidden() && page.attributes.url !== '/') {

        count++;

        xml += '<url><loc>' + baseUrl + page.attributes.url + '</loc>';

        var modDate = new Date(page.attributes.modifiedAt);
        xml += '<lastmod>' + modDate.toISOString() + '</lastmod>';

        var depth = page.attributes.url.split('/').length / 10;
        var priority = 0.5 - depth;
        if (priority < 0.1) priority = 0.1;

        xml += '<priority>' + priority + '</priority>';

        xml += '</url>';
      }
    });

    xml += '</urlset>';

    var path = self.options.outputPath + '/sitemap.xml';
    self.filesystem.writeFile(path, xml);

    self.logger.since(self.namespace, 'Indexed ' + count + ' url(s)', started);
  },

  'run': function (next) {

    var self = this;

    self.generate = _.debounce(self.generate, 1000);
    self.generate();

    self.bindTo(self.options.pages, 'add remove change', 'generate');

    next();
  }
});
<commit_msg>don't log for sitemap generation if no pages<commit_after>var Initializer = require('./Initializer');
var _ = require('lodash');
var _super = Initializer.prototype;

module.exports = Initializer.extend({

  'generate': function () {

    var self = this;
    var started = new Date();
    var baseUrl = 'http://' + self.options.domain_name;
    var count = 0;
    var xml = '';

    xml += '<?xml version="1.0" encoding="utf-8"?>';
    xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

    self.options.pages.each(function (page) {

      if (!page.isHidden() && page.attributes.url !== '/') {

        count++;

        xml += '<url><loc>' + baseUrl + page.attributes.url + '</loc>';

        var modDate = new Date(page.attributes.modifiedAt);
        xml += '<lastmod>' + modDate.toISOString() + '</lastmod>';

        var depth = page.attributes.url.split('/').length / 10;
        var priority = 0.5 - depth;
        if (priority < 0.1) priority = 0.1;

        xml += '<priority>' + priority + '</priority>';

        xml += '</url>';
      }
    });

    xml += '</urlset>';

    var path = self.options.outputPath + '/sitemap.xml';
    self.filesystem.writeFile(path, xml);

    count && self.logger.since(self.namespace, 'Indexed ' + count + ' url(s)', started);
  },

  'run': function (next) {

    var self = this;

    self.generate = _.debounce(self.generate, 1000);
    self.generate();

    self.bindTo(self.options.pages, 'add remove change', 'generate');

    next();
  }
});

{'fraction_non_alphanumeric': 0.1928475935828877, 'fraction_numerical': 0.012032085561497326, 'mean_word_length': 2.676904176904177, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 2, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 24}, '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': '3799970', 'n_tokens_mistral': 1002, 'n_tokens_neox': 932, 'n_words': 212}