<commit_before>/***
 * ScheduleController - Controller for schedule.template.html
 *
 */
angular
    .module('TrackWorkApp')
    .controller('ScheduleController',['$sessionStorage', 'EntryService', ScheduleController]);

function ScheduleController($sessionStorage, EntryService)   {
  var vm = this;

  // Set this to vm.entries for example data
  var exampleEntries = {
    '2016-04-14': [
      {
        'description': 'Did some stuff',
        'start': '2016-04-14T12:00Z',
        'end': '2016-04-14T14:00Z',
        'overtime': true
      },
      {
        'description': 'Did some more stuff',
        'start': '2016-04-14T16:00Z',
        'end': '2016-04-14T19:00Z',
        'overtime': false
      }
    ],
    '2016-04-13': [
      {
        'description': 'Did some stuff',
        'start': '2016-04-13T12:00Z',
        'end': '2016-04-13T14:00Z',
        'overtime': true
      },
      {
        'description': 'Did some more stuff',
        'start': '2016-04-13T16:00Z',
        'end': '2016-04-13T19:00Z',
        'overtime': false
      }
    ]
  };

  /**
   * Retrieves the entries from database and puts them into the view
   *
   */
  function fetchEntries() {
    EntryService.getAll()
      .then(function(data){
        // Success

        if(data.length > 0){
          var entries = {};

          // Sort the entries after day for a pretty display in the partial
          for(x in data){
            // Get the date
            var date = moment(data[x].start, "YYYY-MM-DDTHH:mm:ssZ").format('YYYY-MM-DD');

            if(date in entries){
              entries[date].push(data[x]);
            } else {
              entries[date] = [];
              entries[date].push(data[x]);
            }
          }
          vm.entries = entries;
        }
      }, function(message){
        // Error
        console.error(message);
      });
  }

  vm.save = function() {
    var date = new Date(vm.start);
    if(!vm.entries) {
      vm.entries = {};<commit_msg>Fixed a bug where the page would go blank if you removed all entries<commit_after>/***
 * ScheduleController - Controller for schedule.template.html
 *
 */
angular
    .module('TrackWorkApp')
    .controller('ScheduleController',['$sessionStorage', 'EntryService', ScheduleController]);

function ScheduleController($sessionStorage, EntryService)   {
  var vm = this;

  // Set this to vm.entries for example data
  var exampleEntries = {
    '2016-04-14': [
      {
        'description': 'Did some stuff',
        'start': '2016-04-14T12:00Z',
        'end': '2016-04-14T14:00Z',
        'overtime': true
      },
      {
        'description': 'Did some more stuff',
        'start': '2016-04-14T16:00Z',
        'end': '2016-04-14T19:00Z',
        'overtime': false
      }
    ],
    '2016-04-13': [
      {
        'description': 'Did some stuff',
        'start': '2016-04-13T12:00Z',
        'end': '2016-04-13T14:00Z',
        'overtime': true
      },
      {
        'description': 'Did some more stuff',
        'start': '2016-04-13T16:00Z',
        'end': '2016-04-13T19:00Z',
        'overtime': false
      }
    ]
  };

  /**
   * Retrieves the entries from database and puts them into the view
   *
   */
  function fetchEntries() {
    EntryService.getAll()
      .then(function(data){
        // Success

        if(data.length > 0){
          var entries = {};

          // Sort the entries after day for a pretty display in the partial
          for(x in data){
            // Get the date
            var date = moment(data[x].start, "YYYY-MM-DDTHH:mm:ssZ").format('YYYY-MM-DD');

            if(date in entries){
              entries[date].push(data[x]);
            } else {
              entries[date] = [];
              entries[date].push(data[x]);
            }
          }
          vm.entries = entries;
        } else {
          vm.entries = null;
        }
      }, function(message){
        // Error
        console.error(message);
      });
  }

  vm.save = function() {
    var date = new Date(vm.start);
    if(!vm.entries) {
      vm.entries = {};
{'fraction_non_alphanumeric': 0.15190184049079755, 'fraction_numerical': 0.0554601226993865, 'mean_word_length': 1.8168624740843125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2134597', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1272, 'n_words': 278}