<commit_before>;(function(){

  angular.module('Front-Rails', ['ngRoute'], function($routeProvider){
  $routeProvider
    .when('/', {
      redirectTo: "top-questions"
    })
    .when('/top-questions', {
      templateUrl: 'partials/top-questions.html',  // controller: 'questionList'
    })

    .when('/question/:id', {
      templateUrl: 'partials/question.html',  // controller: 'questionPage'
      controller: 'vote',
    })
  }) //END $routeProvider

  .controller('questionList', function($scope, $routeParams, $http){  //CONTROLLER FOR POPULATING TOP QUESTIONS
    $http.get('https://stackundertow.herokuapp.com/questions')
      .then(function(response){
        $scope.questions = response.data;
      })
  })//CONTROLLER FOR POPULATING TOP QUESTIONS

  .controller("SignupController", function($scope, $http){ //CONTROLLER FOR SIGNUP
    $scope.user = {
      name: '',
      email: '',
      password: ''
    }
    $scope.submit = function() {
      $http.post('https://stackundertow.herokuapp.com/users', $scope.user);
    };
    $scope.user = {
      name: '',
      email: '',
      password: ''
    };
  })//CONTROLLER FOR SIGNUP

  .controller("questionAsker", function($scope, $http, $rootScope){ //CONTROLLER FOR submitting answer

    $rootScope.submitQuestion = function(puzzle, detail) {
      $rootScope.question = {
        query: puzzle,
        description: detail,
        user_id: $rootScope.id
      }
      $http.post('https://stackundertow.herokuapp.com/questions', $rootScope.question)
        .then(function(){
          $scope.question = {
            query: '',
            description: ''
          }
        })
    };
  })//CONTROLLER FOR submitting question

  .controller("OfferAnswer", function($scope, $http, $routeParams, $rootScope){ //CONTROLLER FOR submitting answer
      var id = parseInt($routeParams.id, 10);
      var username = $routeParams.username;
      $scope.username = $routeParams.username;
      $scope.id = $routeParams.id;
      $http.get('https://stackundertow.herokuapp.com/questions/' + id + "/")
        .then(function(response){
          $rootScope.question = response.data;
          $rootScope.query = response.data.query;
          $rootScope.description = response.data.description;
      })


    $rootScope.submitAnswer = function(deets) {
      $rootScope.answers =  {
        user_id: $rootScope.id,
        question_id: id,
        description: deets
      }
      $http.post('https://stackundertow.herokuapp.com/answers', $rootScope.answers)
      .then(function(){
        $scope.answers = {
          description: ''
        }
      })
    };
  })//CONTROLLER FOR submitting answer

  .controller('loginCtrl', function($scope, $http, $window, $rootScope){//CONTROLLER FOR LOGIN
    $scope.user = {
      email: '',
      password: ''
    }
    $scope.submit= function(){
      $http.post('https://stackundertow.herokuapp.com/sessions', $scope.user)
        .success(function (data, status, headers, config) {
          $window.sessionStorage.auth_token = data.auth_token;
          $scope.user = {
            email: '',
            password: ''
          }
          $rootScope.name = data.name;
          $rootScope.id = data.id;
          $rootScope.token = data.auth_token;
        })
      .error(function (data, status, headers, config) {
        alert("Error: Invalid user or password");
      });
    }
  })//CONTROLLER FOR LOGIN

  .controller('vote', function($scope, $http) {
    $scope.upVote = function() {
      console.log("UP VOTE");
    };

    $scope.downVote = function() {
      console.log("DOWN VOTE");
    };

  })//CONTROLLER FOR VOTING<commit_msg>successfully patches votes however recieves 'answer not found' in return<commit_after>;(function(){

  angular.module('Front-Rails', ['ngRoute'], function($routeProvider){
  $routeProvider
    .when('/', {
      redirectTo: "top-questions"
    })
    .when('/top-questions', {
      templateUrl: 'partials/top-questions.html',  // controller: 'questionList'
    })

    .when('/question/:id', {
      templateUrl: 'partials/question.html',  // controller: 'questionPage'
      controller: 'vote',
    })
  }) //END $routeProvider

  .controller('questionList', function($scope, $routeParams, $http){  //CONTROLLER FOR POPULATING TOP QUESTIONS
    $http.get('https://stackundertow.herokuapp.com/questions')
      .then(function(response){
        $scope.questions = response.data;
      })
  })//CONTROLLER FOR POPULATING TOP QUESTIONS

  .controller("SignupController", function($scope, $http){ //CONTROLLER FOR SIGNUP
    $scope.user = {
      name: '',
      email: '',
      password: ''
    }
    $scope.submit = function() {
      $http.post('https://stackundertow.herokuapp.com/users', $scope.user);
    };
    $scope.user = {
      name: '',
      email: '',
      password: ''
    };
  })//CONTROLLER FOR SIGNUP

  .controller("questionAsker", function($scope, $http, $rootScope){ //CONTROLLER FOR submitting answer

    $rootScope.submitQuestion = function(puzzle, detail) {
      $rootScope.question = {
        query: puzzle,
        description: detail,
        user_id: $rootScope.id
      }
      $http.post('https://stackundertow.herokuapp.com/questions', $rootScope.question)
        .then(function(){
          $scope.question = {
            query: '',
            description: ''
          }
        })
    };
  })//CONTROLLER FOR submitting question

  .controller("OfferAnswer", function($scope, $http, $routeParams, $rootScope){ //CONTROLLER FOR submitting answer
      var id = parseInt($routeParams.id, 10);
      var username = $routeParams.username;
      $scope.username = $routeParams.username;
      $scope.id = $routeParams.id;
      $http.get('https://stackundertow.herokuapp.com/questions/' + id + "/")
        .then(function(response){
          $rootScope.question = response.data;
          $rootScope.query = response.data.query;
          $rootScope.description = response.data.description;
      })


    $rootScope.submitAnswer = function(deets) {
      $rootScope.answers =  {
        user_id: $rootScope.id,
        question_id: id,
        description: deets
      }
      $http.post('https://stackundertow.herokuapp.com/answers', $rootScope.answers)
      .then(function(){
        $scope.answers = {
          description: ''
        }
      })
    };
  })//CONTROLLER FOR submitting answer

  .controller('loginCtrl', function($scope, $http, $window, $rootScope){//CONTROLLER FOR LOGIN
    $scope.user = {
      email: '',
      password: ''
    }
    $scope.submit= function(){
      $http.post('https://stackundertow.herokuapp.com/sessions', $scope.user)
        .success(function (data, status, headers, config) {
          $window.sessionStorage.auth_token = data.auth_token;
          $scope.user = {
            email: '',
            password: ''
          }
          $rootScope.name = data.name;
          $rootScope.id = data.id;
          $rootScope.token = data.auth_token;
        })
      .error(function (data, status, headers, config) {
        alert("Error: Invalid user or password");
      });
    }
  })//CONTROLLER FOR LOGIN

  .controller('vote', function($scope, $http) {
    var id = $scope.answer_id;

    $scope.upVote = function() {
      // console.log("UP VOTE");
      $http.patch('https://stackundertow.herokuapp.com/answers/'+ id +'/upvote')
    };

    $scope.downVote = function() {
      // console.log("DOWN VOTE");
      $http.patch('https://stackundertow.herokuapp.com/answers/'+ id +'/downvote')

    };

  })//CONTROLLER FOR VOTING
{'fraction_non_alphanumeric': 0.15799207397622192, 'fraction_numerical': 0.0005284015852047556, 'mean_word_length': 2.4777216352779052, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, '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': '602356', 'n_tokens_mistral': 2403, 'n_tokens_neox': 2297, 'n_words': 403}