<commit_before>'use strict';

angular.module('wbwcpNgApp')
  .controller('MatchesCtrl', function ($scope, $http, User, Auth, $filter) {
    $scope.errors = {};

    // Set up data for the /matches page

    // get all matches from the back-end
    $http.get('/api/matches').success(function(matches) {
      $scope.firstround = matches.slice(0, 48);
      $scope.finals = matches.slice(48);
    });

    // get all users from the back-end
    $http.get('/api/users').success(function(users) {
      $scope.users = users;
    });

    // get all teams
    $http.get('/api/teams').success(function(teams) {
      $scope.teams = teams;
    });

    // get picks for the currently displayed user
    $scope.currentUser = User.get({}, function() {
      if ($scope.currentUser._id) {
        $http.get('/api/picks/' + $scope.currentUser._id).success(function(picks) {
          // array[pick.match] = pick.choice
          var rePicks = [];
          var rePoints = [];
          for (var pick in picks) {
            rePicks[picks[pick].match] = picks[pick].choice;
            rePoints[picks[pick].match] = picks[pick].points;

            if ($scope.beforeKOroundCutoff) {
              // for finals matches, shove picks data/teams into $scope.finals[i]
              var finalsPick = $filter('filter')($scope.finals, {_id: picks[pick].match}, true);
              if (finalsPick[0]) {
                var teamPick = $filter('filter')($scope.teams, {code: picks[pick].choice}, true);
                if (teamPick[0]) {
                  $scope.updateKOPick(finalsPick[0].matchNumber, teamPick[0]);
                }
              }
            }
          }
          $scope.currentPicks = rePicks;
          $scope.currentPoints = rePoints;
          $scope.pickCount = picks.length;

          // special case: bonus for picking all 4 semifinalists correctly
          $scope.currentPoints['semifinalsBonus'] = 0;
          if(
            $scope.currentPoints[$scope.finals[8]._id] != 0 &&
            $scope.currentPoints[$scope.finals[9]._id] != 0 &&
            $scope.currentPoints[$scope.finals[10]._id] != 0 &&
            $scope.currentPoints[$scope.finals[11]._id] != 0
            ) {
            $scope.currentPoints['semifinalsBonus'] = 4;
          }

        });
      }
    });

    $scope.changeUser = function() {
      User.get({ _id: $scope.currentUser._id }, function() {
        if ($scope.currentUser._id) {
          $http.get('/api/picks/' + $scope.currentUser._id).success(function(picks) {
            // reset $scope.finals when changing users
            $http.get('/api/matches').success(function(matches) {
              $scope.finals = matches.slice(48);

              // array[pick.match] = pick.choice
              var rePicks = [];
              var rePoints = [];
              for (var pick in picks) {
                rePicks[picks[pick].match] = picks[pick].choice;
                rePoints[picks[pick].match] = picks[pick].points;

                if ($scope.beforeKOroundCutoff) {
                  // for finals matches, shove picks data/teams into $scope.finals[i]
                  var finalsPick = $filter('filter')($scope.finals, {_id: picks[pick].match}, true);
                  if (finalsPick[0]) {
                    var teamPick = $filter('filter')($scope.teams, {code: picks[pick].choice}, true);
                    if (teamPick[0]) {
                      $scope.updateKOPick(finalsPick[0].matchNumber, teamPick[0]);
                    }
                  }
                }
              }
              // send picks to the front-end
              $scope.currentPicks = rePicks;
              $scope.currentPoints = rePoints;
              $scope.pickCount = picks.length;

              // special case: bonus for picking all 4 semifinalists correctly
              $scope.currentPoints['semifinalsBonus'] = 0;
console.log($scope.currentPoints[$scope.finals[8]._id]);
              if(
                (typeof $scope.currentPoints[$scope.finals[8]._id] != 'undefined' && $scope.currentPoints[$scope.finals[8]._id] != 0) &&
                (typeof $scope.currentPoints[$scope.finals[9]._id] != 'undefined' && $scope.currentPoints[$scope.finals[9]._id] != 0) &&
                (typeof $scope.currentPoints[$scope.finals[10]._id] != 'undefined' && $scope.currentPoints[$scope.finals[10]._id] != 0) &&
                (typeof $scope.currentPoints[$scope.finals[11]._id] != 'undefined' && $scope.currentPoints[$scope.finals[11]._id] != 0)
                ) {
                $scope.currentPoints['semifinalsBonus'] = 4;
              }

            });
          });
        }
      });
    };

    $scope.updateKOPick = function(matchNumber, team) {
      var tbdTeamArray = $filter('filter')($scope.teams, {code: 'tbd'}, true);
      var tbdTeam = tbdTeamArray[0];
      switch(matchNumber) {
        case 49:
          // match #57, old team1
          var oldTeam = $scope.finals[8].team1;
          // update match #57, team1<commit_msg>Oops, remove semifinals bonus debugging line.<commit_after>'use strict';

angular.module('wbwcpNgApp')
  .controller('MatchesCtrl', function ($scope, $http, User, Auth, $filter) {
    $scope.errors = {};

    // Set up data for the /matches page

    // get all matches from the back-end
    $http.get('/api/matches').success(function(matches) {
      $scope.firstround = matches.slice(0, 48);
      $scope.finals = matches.slice(48);
    });

    // get all users from the back-end
    $http.get('/api/users').success(function(users) {
      $scope.users = users;
    });

    // get all teams
    $http.get('/api/teams').success(function(teams) {
      $scope.teams = teams;
    });

    // get picks for the currently displayed user
    $scope.currentUser = User.get({}, function() {
      if ($scope.currentUser._id) {
        $http.get('/api/picks/' + $scope.currentUser._id).success(function(picks) {
          // array[pick.match] = pick.choice
          var rePicks = [];
          var rePoints = [];
          for (var pick in picks) {
            rePicks[picks[pick].match] = picks[pick].choice;
            rePoints[picks[pick].match] = picks[pick].points;

            if ($scope.beforeKOroundCutoff) {
              // for finals matches, shove picks data/teams into $scope.finals[i]
              var finalsPick = $filter('filter')($scope.finals, {_id: picks[pick].match}, true);
              if (finalsPick[0]) {
                var teamPick = $filter('filter')($scope.teams, {code: picks[pick].choice}, true);
                if (teamPick[0]) {
                  $scope.updateKOPick(finalsPick[0].matchNumber, teamPick[0]);
                }
              }
            }
          }
          $scope.currentPicks = rePicks;
          $scope.currentPoints = rePoints;
          $scope.pickCount = picks.length;

          // special case: bonus for picking all 4 semifinalists correctly
          $scope.currentPoints['semifinalsBonus'] = 0;
          if(
            $scope.currentPoints[$scope.finals[8]._id] != 0 &&
            $scope.currentPoints[$scope.finals[9]._id] != 0 &&
            $scope.currentPoints[$scope.finals[10]._id] != 0 &&
            $scope.currentPoints[$scope.finals[11]._id] != 0
            ) {
            $scope.currentPoints['semifinalsBonus'] = 4;
          }

        });
      }
    });

    $scope.changeUser = function() {
      User.get({ _id: $scope.currentUser._id }, function() {
        if ($scope.currentUser._id) {
          $http.get('/api/picks/' + $scope.currentUser._id).success(function(picks) {
            // reset $scope.finals when changing users
            $http.get('/api/matches').success(function(matches) {
              $scope.finals = matches.slice(48);

              // array[pick.match] = pick.choice
              var rePicks = [];
              var rePoints = [];
              for (var pick in picks) {
                rePicks[picks[pick].match] = picks[pick].choice;
                rePoints[picks[pick].match] = picks[pick].points;

                if ($scope.beforeKOroundCutoff) {
                  // for finals matches, shove picks data/teams into $scope.finals[i]
                  var finalsPick = $filter('filter')($scope.finals, {_id: picks[pick].match}, true);
                  if (finalsPick[0]) {
                    var teamPick = $filter('filter')($scope.teams, {code: picks[pick].choice}, true);
                    if (teamPick[0]) {
                      $scope.updateKOPick(finalsPick[0].matchNumber, teamPick[0]);
                    }
                  }
                }
              }
              // send picks to the front-end
              $scope.currentPicks = rePicks;
              $scope.currentPoints = rePoints;
              $scope.pickCount = picks.length;

              // special case: bonus for picking all 4 semifinalists correctly
              $scope.currentPoints['semifinalsBonus'] = 0;
              if(
                (typeof $scope.currentPoints[$scope.finals[8]._id] != 'undefined' && $scope.currentPoints[$scope.finals[8]._id] != 0) &&
                (typeof $scope.currentPoints[$scope.finals[9]._id] != 'undefined' && $scope.currentPoints[$scope.finals[9]._id] != 0) &&
                (typeof $scope.currentPoints[$scope.finals[10]._id] != 'undefined' && $scope.currentPoints[$scope.finals[10]._id] != 0) &&
                (typeof $scope.currentPoints[$scope.finals[11]._id] != 'undefined' && $scope.currentPoints[$scope.finals[11]._id] != 0)
                ) {
                $scope.currentPoints['semifinalsBonus'] = 4;
              }

            });
          });
        }
      });
    };

    $scope.updateKOPick = function(matchNumber, team) {
      var tbdTeamArray = $filter('filter')($scope.teams, {code: 'tbd'}, true);
      var tbdTeam = tbdTeamArray[0];
      switch(matchNumber) {
        case 49:
          // match #57, old team1
          var oldTeam = $scope.finals[8].team1;
          // update match #57, team1
{'fraction_non_alphanumeric': 0.15288220551378445, 'fraction_numerical': 0.011729323308270676, 'mean_word_length': 1.9135514018691588, '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': '3726462', 'n_tokens_mistral': 3087, 'n_tokens_neox': 2881, 'n_words': 529}