<commit_before>define([
  'jQuery-2.1.4.min',
	'underscore_1.3.3',
	'backbone_0.9.2',
  './PageSectionModel',
], function ($, _, Backbone, PageSectionModel) {

  
  //Create an empty Collection to hold all the posts.
  var PageSectionCollection = Backbone.Collection.extend({ //Collection Class
    model: PageSectionModel,
    //url: 'http://'+global.serverIp+':'+global.serverPort+'/api/pagesection/list',
    url: '',

    //parse is called when data is returned from the server after a fetch() call.
    //Parse allows me to massage non-standard data before it is returned to the collection.
    parse: function(response) {
      //debugger;
      return response.pagesection;
      
      if(response.pagesection.length == 0) {
        log.push('Empty data returned by server when trying to retrieve PageSection collection. Most likely due to a new DB.');
        return [global.pageSectionModel];
      } else {
        return response.pagesection;
      }
    },

    refreshView: false,
    
    initialize: function() {
      //this.on('change', function(model) {
      //  debugger;
      //});

      this.url = 'http://'+global.serverIp+':'+global.serverPort+'/api/pagesection/list',
      
      this.on('add', function() {
        debugger;
      });

      this.on('reset', function() {
        //debugger;

        if(this.refreshView) {
          this.refreshView = false;
          global.sectionsView.render();
        }
        
        //Assumption: this funciton is only called when opening the image gallery. Therefore we need to call it again and
        //finish populating the image library.
        log.push('Finished retrieving PageSectionCollection data from server.');

        //global.pagesView.populateTable();
      });
    }
  });
  
  return PageSectionCollection;

});
<commit_msg>fixing functionality with empty DB<commit_after>define([
  'jQuery-2.1.4.min',
	'underscore_1.3.3',
	'backbone_0.9.2',
  './PageSectionModel',
], function ($, _, Backbone, PageSectionModel) {

  
  //Create an empty Collection to hold all the posts.
  var PageSectionCollection = Backbone.Collection.extend({ //Collection Class
    model: PageSectionModel,
    //url: 'http://'+global.serverIp+':'+global.serverPort+'/api/pagesection/list',
    url: '',

    //parse is called when data is returned from the server after a fetch() call.
    //Parse allows me to massage non-standard data before it is returned to the collection.
    parse: function(response) {
      //debugger;
      
      if(response.pagesection.length == 0) {
        log.push('Empty data returned by server when trying to retrieve PageSection collection. Most likely due to a new DB.');
        return [global.pageSectionModel];
      } else {
        return response.pagesection;
      }
    },

    refreshView: false,
    
    initialize: function() {
      //this.on('change', function(model) {
      //  debugger;
      //});

      this.url = 'http://'+global.serverIp+':'+global.serverPort+'/api/pagesection/list',
      
      this.on('add', function() {
        debugger;
      });

      this.on('reset', function() {
        //debugger;

        if(this.refreshView) {
          this.refreshView = false;
          global.sectionsView.render();
        }
        
        //Assumption: this funciton is only called when opening the image gallery. Therefore we need to call it again and
        //finish populating the image library.
        log.push('Finished retrieving PageSectionCollection data from server.');

        //global.pagesView.populateTable();
      });
    }
  });
  
  return PageSectionCollection;

});

{'fraction_non_alphanumeric': 0.12810601877415792, 'fraction_numerical': 0.005521811154058531, 'mean_word_length': 2.45706106870229, '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': '5890652', 'n_tokens_mistral': 1030, 'n_tokens_neox': 1013, 'n_words': 276}