<commit_before>// create a goal
  // choose a category
    // choose a number of target hours
      // post to server new goal
      // display new goal

angular.module('goals', [])

.controller('goalsController', ['$scope', 'goalsFactory', function($scope, goalsFactory) {
  $scope.categories = goalsFactory.categories;
  $scope.goals = goalsFactory.goals;

  $scope.createGoal = function(category, time) {
    var goal = {
      userID: 'testID', //TODO: Update this to username from global factoryvar
      category: category,
      activity: category, //TODO: Update this to activity from $scope
      time: time
    };

    $scope.goals[goal.activity] = goal;
    $scope.postGoal(goal);
    return goal;
  };

  $scope.postGoal = function(goal) {
    goalsFactory.sendData(goal)
    .then(goalsFactory.getAllData).then(function(response) {console.log(response.data)});
  }

  goalsFactory.getAllData().then(function(response) {
    response.data.forEach(function(goal) {
    $scope.goals[goal.activity] = goal;
  })});
}])

.factory('goalsFactory', ['$http', function($http) {
  var categories = [
    { name: 'Sleep', time: 0, colorClass: 'panel-primary' },
    { name: 'Fun', time: 0, colorClass: 'panel-green' },
    { name: 'Work', time: 0, colorClass: 'panel-red' },
    { name: 'Development', time: 0, colorClass: 'panel-yellow'}
  ];
  var goals = {};

  var sendData = function(payload){
    return $http.post('/api/goals', payload)
  };
  var getAllData = function(user){
    // until user login is implemented, userID can be specified in headers.
    return $http.get('/api/goals', {headers: {'x-userid': 'testID'}});
  }

  return {
    categories: categories,
    goals: goals,
    sendData: sendData,
    getAllData: getAllData
  }
}])


// view goals
  // display actual time and goal time --> eventually display bar chart of activity time vs goal time
    // click on button to edit goal --> eventually click on bar to edit goal
      // on edit goal interface choose a new number of target hours
        // put to server updated goal
        // return to default goal view, displaying updated goal

// TODO goal integration with main view
  // inspiring callouts when you make progress on a goal
  // nagging reminders when you get close to a goal in a 'negative' category
  // neutral callout when you do an activity you don't have a goal for

// TODO create daily or weekly goals

// TODO make suggestions on how to achieve goals based on activity history

// goal schema:
/*
 {
   userID: String,
   category: String,
   activity: String,
   time: Number
 }
*/
<commit_msg>Implement sign in by ID<commit_after>// create a goal
  // choose a category
    // choose a number of target hours
      // post to server new goal
      // display new goal

angular.module('goals', [])

.controller('goalsController', ['$rootScope', '$scope', 'goalsFactory', function($rootScope, $scope, goalsFactory) {
  $scope.categories = goalsFactory.categories;
  $scope.goals = goalsFactory.goals;

  $scope.createGoal = function(category, time) {
    var goal = {
      userID: $rootScope.user.data.id,
      category: category,
      activity: category, //TODO: Update this to activity from $scope
      time: time
    };

    $scope.goals[goal.activity] = goal;
    $scope.postGoal(goal);
    return goal;
  };

  $scope.postGoal = function(goal) {
    goalsFactory.sendData(goal)
    .then(goalsFactory.getAllData).then(function(response) {console.log(response.data)});
  }

  goalsFactory.getAllData().then(function(response) {
    response.data.forEach(function(goal) {
    $scope.goals[goal.activity] = goal;
  })});
}])

.factory('goalsFactory', ['$http', function($http) {
  var categories = [
    { name: 'Sleep', time: 0, colorClass: 'panel-primary' },
    { name: 'Fun', time: 0, colorClass: 'panel-green' },
    { name: 'Work', time: 0, colorClass: 'panel-red' },
    { name: 'Development', time: 0, colorClass: 'panel-yellow'}
  ];
  var goals = {};

  var sendData = function(payload){
    return $http.post('/api/goals', payload)
  };
  var getAllData = function(user){
    var id = $rootScope.user.data.id;
    return $http.get('/api/goals', {headers: {'x-userid': id}});
  }

  return {
    categories: categories,
    goals: goals,
    sendData: sendData,
    getAllData: getAllData
  }
}])


// view goals
  // display actual time and goal time --> eventually display bar chart of activity time vs goal time
    // click on button to edit goal --> eventually click on bar to edit goal
      // on edit goal interface choose a new number of target hours
        // put to server updated goal
        // return to default goal view, displaying updated goal

// TODO goal integration with main view
  // inspiring callouts when you make progress on a goal
  // nagging reminders when you get close to a goal in a 'negative' category
  // neutral callout when you do an activity you don't have a goal for

// TODO create daily or weekly goals

// TODO make suggestions on how to achieve goals based on activity history

// goal schema:
/*
 {
   userID: String,
   category: String,
   activity: String,
   time: Number
 }
*/

{'fraction_non_alphanumeric': 0.12767197823552273, 'fraction_numerical': 0.001554605518849592, 'mean_word_length': 3.124198717948718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3910137', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1528, 'n_words': 514}