<commit_before>define([
  "require",
  "namespace",

  // Libs
  "use!backbone",

  // Modules
  "modules/leaguevine",
],

function(require, namespace, Backbone, Leaguevine) {
	var app = namespace.app;
	var PlayerPerGameStats = namespace.module();
	
	//
	// MODEL
	//
	PlayerPerGameStats.Model = Backbone.Model.extend({
		defaults: {// Include defaults for any attribute that will be rendered.
            game: {id: ''},
            league: {},
            player: {id: ''},
            season: {},
            team: {id: ''},
            tournament: {},
            player_id: "",
            callahans: "",
            completed_passes_thrown: "",
            completion_percent: "",
            defense_plus_minus: "",
            drops: "",
            ds: "",
            goals_caught: "",
            goals_thrown: "",
            incomplete_passes_thrown: "",
            offense_plus_minus: "",
            passes_caught: "",
            passes_thrown: "",
            picked_up_disc: "",
            plus_minus: "",
            points_played: "",
            pulls: "",
            throwaways: "",
            turnovers: "",
		},
        idAttribute: "player_id", // The unique identifier in a collection is a player. A player who is on both
                                  // teams in the same game could cause problems here.
		urlRoot: Leaguevine.API.root + "stats/ultimate/player_stats_per_game",
		parse: function(resp, xhr) {
			resp = Backbone.Model.prototype.parse(resp);
			return resp;
		},
		toJSON: function() {
			return _.clone(this.attributes);
		}
	});

	//
	// COLLECTION
	//
	PlayerPerGameStats.Collection = Backbone.Collection.extend({
		model: PlayerPerGameStats.Model,
		urlRoot: Leaguevine.API.root + "stats/ultimate/player_stats_per_game",
		url: function(models) {
			var url = this.urlRoot || ( models && models.length && models[0].urlRoot );
			url += '/?';
            if (this.game_ids) {
                url += 'game_ids=[' + this.game_ids + ']&';
            }
            if (this.player_ids) {
                url += 'player_ids[' + this.player_ids + ']&';
            }
			url += 'limit=30&';
            url += 'order_by=[-points_played, -goals_caught, -goals_thrown]';
			return url;
		},
		comparator: function(stat_line) {// Define how items in the collection will be sorted.
            return stat_line.get("points_played");
		},
		parse: function(resp, xhr) {
			resp = Backbone.Collection.prototype.parse(resp);
			return resp;
		},
		initialize: function(models, options) {
			if (options) {
        		this.game_ids = options.game_ids;
        		this.player_ids = options.player_ids;
    		}
		}
	});

	//
	// VIEWS
	//
	PlayerPerGameStats.Views.PlayerStats = Backbone.View.extend({
		template: "playerstats/per_game_stat_line",
		tagName: "tr",
		serialize: function() {return this.model.toJSON();}
	});
    PlayerPerGameStats.Views.BoxScore = Backbone.LayoutManager.View.extend({
        /* Usage:
         *     required arguments:
         *          game - The game object you are rendering a box score for
         */
		template: "playerstats/boxscore",
		className: "playerstats-boxscore-wrapper",
        serialize: function() {debugger; return this.options.game.toJSON();},
		render: function(layout) {
			var view = layout(this);
			this.$el.empty();
            var team_1_id = this.options.game.get('team_1_id');
            var team_2_id = this.options.game.get('team_2_id');
			this.collection.each(function(playerstats) {
                // Render a single line of stats for a player
                stat_line = new PlayerPerGameStats.Views.PlayerStats({model: playerstats});

                // Check which team's boxscore the stat line should be appended to
                if (playerstats.get('team_id') == team_1_id) {
                    view.insert("table#player_per_game_stats_1", stat_line);
                }
                else if (playerstats.get('team_id') == team_2_id) {
                    view.insert("table#player_per_game_stats_2", stat_line);
                }
			});
			return view.render();
		},
		initialize: function() {
			this.collection.bind("reset", function() {
				this.render();
			}, this);
		},
	});
    PlayerPerGameStats.Views.PlayerStatsList = Backbone.LayoutManager.View.extend({
		template: "playerstats/list",
		className: "playersstats_list_wrapper",
		render: function(layout) {
			var view = layout(this);
			this.$el.empty();
			this.collection.each(function(playerstats) {
				view.insert("table", new PlayerPerGameStats.Views.PlayerStats({
					model: playerstats
				}));
			});
			return view.render();
		},
		initialize: function() {
			this.collection.bind("reset", function() {
				this.render();
			}, this);
		},
	});

    return PlayerPerGameStats;
});
<commit_msg>Removed debugger I accidentally left in<commit_after>define([
  "require",
  "namespace",

  // Libs
  "use!backbone",

  // Modules
  "modules/leaguevine",
],

function(require, namespace, Backbone, Leaguevine) {
	var app = namespace.app;
	var PlayerPerGameStats = namespace.module();
	
	//
	// MODEL
	//
	PlayerPerGameStats.Model = Backbone.Model.extend({
		defaults: {// Include defaults for any attribute that will be rendered.
            game: {id: ''},
            league: {},
            player: {id: ''},
            season: {},
            team: {id: ''},
            tournament: {},
            player_id: "",
            callahans: "",
            completed_passes_thrown: "",
            completion_percent: "",
            defense_plus_minus: "",
            drops: "",
            ds: "",
            goals_caught: "",
            goals_thrown: "",
            incomplete_passes_thrown: "",
            offense_plus_minus: "",
            passes_caught: "",
            passes_thrown: "",
            picked_up_disc: "",
            plus_minus: "",
            points_played: "",
            pulls: "",
            throwaways: "",
            turnovers: "",
		},
        idAttribute: "player_id", // The unique identifier in a collection is a player. A player who is on both
                                  // teams in the same game could cause problems here.
		urlRoot: Leaguevine.API.root + "stats/ultimate/player_stats_per_game",
		parse: function(resp, xhr) {
			resp = Backbone.Model.prototype.parse(resp);
			return resp;
		},
		toJSON: function() {
			return _.clone(this.attributes);
		}
	});

	//
	// COLLECTION
	//
	PlayerPerGameStats.Collection = Backbone.Collection.extend({
		model: PlayerPerGameStats.Model,
		urlRoot: Leaguevine.API.root + "stats/ultimate/player_stats_per_game",
		url: function(models) {
			var url = this.urlRoot || ( models && models.length && models[0].urlRoot );
			url += '/?';
            if (this.game_ids) {
                url += 'game_ids=[' + this.game_ids + ']&';
            }
            if (this.player_ids) {
                url += 'player_ids[' + this.player_ids + ']&';
            }
			url += 'limit=30&';
            url += 'order_by=[-points_played, -goals_caught, -goals_thrown]';
			return url;
		},
		comparator: function(stat_line) {// Define how items in the collection will be sorted.
            return stat_line.get("points_played");
		},
		parse: function(resp, xhr) {
			resp = Backbone.Collection.prototype.parse(resp);
			return resp;
		},
		initialize: function(models, options) {
			if (options) {
        		this.game_ids = options.game_ids;
        		this.player_ids = options.player_ids;
    		}
		}
	});

	//
	// VIEWS
	//
	PlayerPerGameStats.Views.PlayerStats = Backbone.View.extend({
		template: "playerstats/per_game_stat_line",
		tagName: "tr",
		serialize: function() {return this.model.toJSON();}
	});
    PlayerPerGameStats.Views.BoxScore = Backbone.LayoutManager.View.extend({
        /* Usage:
         *     required arguments:
         *          game - The game object you are rendering a box score for
         */
		template: "playerstats/boxscore",
		className: "playerstats-boxscore-wrapper",
        serialize: function() {return this.options.game.toJSON();},
		render: function(layout) {
			var view = layout(this);
			this.$el.empty();
            var team_1_id = this.options.game.get('team_1_id');
            var team_2_id = this.options.game.get('team_2_id');
			this.collection.each(function(playerstats) {
                // Render a single line of stats for a player
                stat_line = new PlayerPerGameStats.Views.PlayerStats({model: playerstats});

                // Check which team's boxscore the stat line should be appended to
                if (playerstats.get('team_id') == team_1_id) {
                    view.insert("table#player_per_game_stats_1", stat_line);
                }
                else if (playerstats.get('team_id') == team_2_id) {
                    view.insert("table#player_per_game_stats_2", stat_line);
                }
			});
			return view.render();
		},
		initialize: function() {
			this.collection.bind("reset", function() {
				this.render();
			}, this);
		},
	});
    PlayerPerGameStats.Views.PlayerStatsList = Backbone.LayoutManager.View.extend({
		template: "playerstats/list",
		className: "playersstats_list_wrapper",
		render: function(layout) {
			var view = layout(this);
			this.$el.empty();
			this.collection.each(function(playerstats) {
				view.insert("table", new PlayerPerGameStats.Views.PlayerStats({
					model: playerstats
				}));
			});
			return view.render();
		},
		initialize: function() {
			this.collection.bind("reset", function() {
				this.render();
			}, this);
		},
	});

    return PlayerPerGameStats;
});

{'fraction_non_alphanumeric': 0.13881935753024613, 'fraction_numerical': 0.00229453483521068, 'mean_word_length': 2.267120954003407, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4874541', 'n_tokens_mistral': 3121, 'n_tokens_neox': 2876, 'n_words': 568}