<commit_before>
angular.module('os.administrative.models.container', ['os.common.models'])
  .factory('Container', function(osModel, $q, $http) {
    var Container = new osModel('storage-containers');

    Container.list = function() {
      return Container.query();
    };

    Container.listForSite = function(siteName, onlyFreeContainers, flatten) {
      var params = {
        site: siteName,
        onlyFreeContainers: !!onlyFreeContainers,
        flatten: !flatten
      };
      return Container.query(params);
    };

    Container.flatten = function(containers) {
      return Container._flatten(containers, 'childContainers');
    };

    Container.prototype.getChildContainers = function(anyLevel) {
      return Container.query({parentContainerId: this.$id(), anyLevelContainers: anyLevel});
    };

    Container.prototype.getOccupiedPositions = function() {
      return $http.get(Container.url() + '/' + this.$id() + '/occupied-positions').then(
        function(result) {
          return result.data;
        }
      );
    };

    return Container;
  });<commit_msg>Fix list containers by site JS for use in add/edit container page<commit_after>
angular.module('os.administrative.models.container', ['os.common.models'])
  .factory('Container', function(osModel, $q, $http) {
    var Container = new osModel('storage-containers');

    Container.list = function() {
      return Container.query();
    };

    Container.listForSite = function(siteName, onlyFreeContainers, flatten) {
      var params = {
        site: siteName,
        anyLevelContainers: true,
        onlyFreeContainers: !!onlyFreeContainers
      };

      var ret = Container.query(params);
      if (flatten == true) {
        ret = ret.then(
          function(containers) {
            return Container._flatten(containers, 'childContainers');
          }
        );
      }
        
      return ret;
    };

    Container.flatten = function(containers) {
      return Container._flatten(containers, 'childContainers');
    };

    Container.prototype.getChildContainers = function(anyLevel) {
      return Container.query({parentContainerId: this.$id(), anyLevelContainers: anyLevel});
    };

    Container.prototype.getOccupiedPositions = function() {
      return $http.get(Container.url() + '/' + this.$id() + '/occupied-positions').then(
        function(result) {
          return result.data;
        }
      );
    };

    return Container;
  });
{'fraction_non_alphanumeric': 0.13289849164288625, 'fraction_numerical': 0.0, 'mean_word_length': 2.8524332810047097, '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': '2553793', 'n_tokens_mistral': 695, 'n_tokens_neox': 677, 'n_words': 127}