<commit_before>/*
 * A model representing a feed version
 */

var _ = require('underscore');
var Backbone = require('Backbone');

module.exports = Backbone.Model.extend({
    defaults: {
        id: null,
        feedSource: null,
        user: null,
        notes: null,
        validationResults: null,
        updated: null,
        version: null
    },
    urlRoot: 'api/feedversions/',

    change: function () {
      var vr = this.get('validationResult');
      vr.errorCount = 0;
      try {
        vr.errorCount += vr.routes.invalidValues.length;
      } catch (e) {}
      try {
        vr.errorCount += vr.stops.invalidValues.length;
      } catch (e) {}
      try {
        vr.errorCount += vr.shapes.invalidValues.length;
      } catch (e) {}
      try {
        vr.errorCount += vr.trips.invalidValues.length;
      } catch (e) {}

      this.set('validationResult', vr);
    },

    initialize: function () {
      _.bindAll(this, 'change');
      this.on('add', this.change);
      this.change();
    }
});<commit_msg>dynamically create error count.<commit_after>/*
 * A model representing a feed version
 */

var _ = require('underscore');
var Backbone = require('Backbone');

module.exports = Backbone.Model.extend({
  defaults: {
    id: null,
    feedSource: null,
    user: null,
    notes: null,
    validationResults: null,
    updated: null,
    version: null
  },
  urlRoot: 'api/feedversions/',

  change: function() {
    var vr = this.get('validationResult');

    if (!_.isUndefined(vr)) {
      vr.errorCount = 0;
      try {
        vr.errorCount += vr.routes.invalidValues.length;
      } catch (e) {}
      try {
        vr.errorCount += vr.stops.invalidValues.length;
      } catch (e) {}
      try {
        vr.errorCount += vr.shapes.invalidValues.length;
      } catch (e) {}
      try {
        vr.errorCount += vr.trips.invalidValues.length;
      } catch (e) {}

      this.set('validationResult', vr);
    }
  },

  initialize: function() {
    _.bindAll(this, 'change');
    this.on('add', this.change);
    this.change();
  }
});
{'fraction_non_alphanumeric': 0.15002411963338158, 'fraction_numerical': 0.000964785335262904, 'mean_word_length': 2.2456964006259783, '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': '2482417', 'n_tokens_mistral': 658, 'n_tokens_neox': 660, 'n_words': 139}