<commit_before>;(function(_, Backbone, storybase) {

  if (_.isUndefined(storybase.badges.models)) {
    storybase.badges.models = {};
  }

  if (_.isUndefined(storybase.badges.collections)) {
    storybase.badges.collections = {};
  }

  var Badge = Backbone.Model.extend({

  });

  var Badges = Backbone.Collection.extend(
    _.extend({}, storybase.collections.TastypieMixin, {
      url: function() {
        return storybase.API_ROOT + 'badges/';
      },
      model: Badge
    })
  );

  var StoryBadges = function(story) {
    this.story = story;
    this.story_id = this.story.id;
    this.storyUri = storybase.API_ROOT + 'stories/' + this.story_id + '/';
  }

  StoryBadges.prototype.addBadge = function(badge) {
    var stories = badge.get('stories');
    stories.push(this.storyUri);

    badge.save({stories: stories}, {patch: true});

    return this;
  }

  var Story = storybase.models.Story;

  storybase.badges.models.Badge = Badge;
  storybase.badges.collections.Badges = Badges;
  storybase.badges.models.StoryBadges = StoryBadges;

})(_, Backbone, storybase);<commit_msg>Story badges method for removing badges<commit_after>;(function(_, Backbone, storybase) {

  if (_.isUndefined(storybase.badges.models)) {
    storybase.badges.models = {};
  }

  if (_.isUndefined(storybase.badges.collections)) {
    storybase.badges.collections = {};
  }

  var Badge = Backbone.Model.extend({

  });

  var Badges = Backbone.Collection.extend(
    _.extend({}, storybase.collections.TastypieMixin, {
      url: function() {
        return storybase.API_ROOT + 'badges/';
      },
      model: Badge
    })
  );

  var StoryBadges = function(story) {
    this.story = story;
    this.storyId = this.story.id;
    this.storyUri = storybase.API_ROOT + 'stories/' + this.storyId + '/';
  }

  StoryBadges.prototype.add = function(badge) {
    var stories = badge.get('stories');
    stories.push(this.storyUri);

    badge.save({stories: stories}, {patch: true});

    return this;
  }

  StoryBadges.prototype.remove = function(badge) {

    var stories = _.filter(badge.get('stories'), function(s) {
      return s != this.storyUri;
    }, this);

    badge.save({stories: stories}, {patch: true});

    return this;
  }

  var Story = storybase.models.Story;

  storybase.badges.models.Badge = Badge;
  storybase.badges.collections.Badges = Badges;
  storybase.badges.models.StoryBadges = StoryBadges;

})(_, Backbone, storybase);
{'fraction_non_alphanumeric': 0.14864864864864866, 'fraction_numerical': 0.0, 'mean_word_length': 3.2784588441331, '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': '2982256', 'n_tokens_mistral': 864, 'n_tokens_neox': 830, 'n_words': 136}