<commit_before>'use strict'

angular.module('pathwayApp')
.controller('ProjectController', function ($scope, $http, $stateParams, $state) {
  $http({method: 'GET',
         url: '/api/pathways/' + $stateParams.pathway_id + '/projects/' + $stateParams.id
  }).success(function(data, status){
    $scope.project = data
  })
  $scope.projects = $http({method: 'GET',
         url: '/api/projects'
  }).success(function(data, status){
    $scope.allProjects = data
  })
  $scope.create = function() {
    $http({method: 'POST',
      url: '/api/projects',
      data: {project: $scope.project } 
    }).success(function(data, status){
      console.log("hello from create()")
      $state.go('home')
    }).error(function(data){
      console.log(data)
    })
  }
  var currentPathway = 0
  $scope.projectsAdded = []
  $scope.addProject = function(project, donated_weight) {
    var projectObj = project
    $http({method: 'POST',
      url: '/api/pathways/' + $stateParams.id + '/projects',
      data: {projects: project, weight: donated_weight } 
    }).success(function(data, status){
      currentPathway = data.pathway_id
      $scope.projectsAdded.push(projectObj.name)
    }).error(function(data){
      console.log("Error adding project")
    })
  }
  $scope.nextPage = function() {
    if (currentPathway == 0) { history.back() }
    else { $state.go('showPathway', {'id': currentPathway}) }
  }
});<commit_msg>Add functionality to redirect once 10 projects are added to the pathway<commit_after>'use strict'

angular.module('pathwayApp')
.controller('ProjectController', function ($scope, $http, $stateParams, $state) {
  $http({method: 'GET',
         url: '/api/pathways/' + $stateParams.pathway_id + '/projects/' + $stateParams.id
  }).success(function(data, status){
    $scope.project = data
  })
  $scope.projects = $http({method: 'GET',
         url: '/api/projects'
  }).success(function(data, status){
    $scope.allProjects = data
  })
  $scope.create = function() {
    $http({method: 'POST',
      url: '/api/projects',
      data: {project: $scope.project } 
    }).success(function(data, status){
      console.log("hello from create()")
      $state.go('home')
    }).error(function(data){
      console.log(data)
    })
  }
  var projects = 0
  var currentPathway = 0
  $scope.projectsAdded = []
  $scope.addProject = function(project, donated_weight) {
    var projectObj = project
    $http({method: 'POST',
      url: '/api/pathways/' + $stateParams.id + '/projects',
      data: {projects: project, weight: donated_weight } 
    }).success(function(data, status){
      projects += 1
      currentPathway = data.pathway_id
      $scope.projectsAdded.push(projectObj.name)
      if (projects == 10) {$state.go('showPathway', {'id': currentPathway })} 
    }).error(function(data){
      console.log("Error adding project")
    })
  }
  $scope.nextPage = function() {
    if (currentPathway == 0) { history.back() }
    else { $state.go('showPathway', {'id': currentPathway}) }
  }
});
{'fraction_non_alphanumeric': 0.17574750830564784, 'fraction_numerical': 0.0033222591362126247, 'mean_word_length': 3.3701015965166907, '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': '1087692', 'n_tokens_mistral': 966, 'n_tokens_neox': 945, 'n_words': 194}