<commit_before>// Licensed to Cloudera, Inc. under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  Cloudera, Inc. licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var HueFileEntry = (function () {
  var self = this;
  self.loading = ko.observable(false);

  var sorts = {
    defaultAsc: function (a, b) {
      if (a.isDirectory() && !b.isDirectory()) {
        return -1;
      }
      if (!a.isDirectory() && b.isDirectory()) {
        return 1;
      }
      if (a.isDirectory() && b.isDirectory()) {
        return sorts.nameAsc(a, b);
      }
      return sorts.lastModifiedDesc(a, b);
    },
    nameAsc: function (a, b) {
      return a.definition().name.localeCompare(b.definition().name);
    },
    nameDesc: function (a, b) {
      return sorts.nameAsc(b, a);
    },
    descriptionAsc: function (a, b) {
      return a.definition().description.localeCompare(b.definition().description);
    },
    descriptionDesc: function (a, b) {
      return sorts.descriptionAsc(b, a);
    },
    typeAsc: function (a, b) {
      return a.definition().type.localeCompare(b.definition().type);
    },
    typeDesc: function (a, b) {
      return sorts.typeAsc(b, a);
    },
    ownerAsc: function (a, b) {
      return a.definition().owner.localeCompare(b.definition().owner);
    },
    ownerDesc: function (a, b) {
      return sorts.ownerAsc(b, a);
    },
    lastModifiedAsc: function (a, b) {
      return a.definition().last_modified_ts - b.definition().last_modified_ts;
    },
    lastModifiedDesc: function (a, b) {
      return sorts.lastModifiedAsc(b, a);
    }
  };

  /**
   *
   * @param {Object} options
   * @param {ApiHelper} options.apiHelper
   * @param {Object} options.definition
   * @param {Function} options.activeEntry - The observable keeping track of the current open directory
   * @param {Function} options.trashEntry - The observable keeping track of the trash directory
   * @param {HueFolder} options.parent
   * @param {string} options.app - Currently only 'documents' is supported
   * @param {string} options.user
   *
   * @constructor
   */
  function HueFileEntry (options) {
    var self = this;
    self.activeEntry = options.activeEntry;
    self.trashEntry = options.trashEntry;
    self.parent = options.parent;
    self.definition = ko.observable(options.definition);
    self.apiHelper = options.apiHelper;
    self.app = options.app;
    self.user = options.user;
    self.superuser = options.superuser;
    self.serverTypeFilter = options.serverTypeFilter || ko.observable({ type: 'all' });
    self.statsVisible = ko.observable(false);
    self.highlight = ko.observable(false);

    self.document = ko.observable();
    self.selectedDocsWithDependents = ko.observable([]);
    self.importedDocSummary = ko.observable();
    self.showTable = ko.observable();
    self.entries = ko.observableArray([]);

    // Filter is only used in the assist panel at the moment
    self.isFilterVisible = ko.observable(false);
    self.filter = ko.observable('').extend({ rateLimit: 400 });

    self.typeFilter = options.typeFilter || ko.observable(DOCUMENT_TYPES[0]); // First one is always 'all'

    self.isFilterVisible.subscribe(function (newValue) {
      if (!newValue && self.filter()) {
        self.filter('');
      }
    });

    self.filteredEntries = ko.pureComputed(function () {
      var filter = self.filter().toLowerCase();
      var typeFilter = self.typeFilter().type;
      if (filter || typeFilter !== 'all') {
        return self.entries().filter(function (entry) {
          var entryType = entry.definition().type;
          return (typeFilter === 'all' || entryType === typeFilter || entryType === 'directory')
            && (!filter || entry.definition().name.toLowerCase().indexOf(filter) !== -1 ||
            (HUE_I18n.documentType[entryType] && HUE_I18n.documentType[entryType].toLowerCase().indexOf(filter) !== -1));
        })
      }
      return self.entries();
    });

    self.getSelectedDocsWithDependents = function() {
      self.selectedDocsWithDependents([]);
      var uuids = self.selectedEntries().map(function(entry) {
        return entry.definition().uuid;<commit_msg>HUE-8192 [assist] Include description in the assist document filter<commit_after>// Licensed to Cloudera, Inc. under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  Cloudera, Inc. licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var HueFileEntry = (function () {
  var self = this;
  self.loading = ko.observable(false);

  var sorts = {
    defaultAsc: function (a, b) {
      if (a.isDirectory() && !b.isDirectory()) {
        return -1;
      }
      if (!a.isDirectory() && b.isDirectory()) {
        return 1;
      }
      if (a.isDirectory() && b.isDirectory()) {
        return sorts.nameAsc(a, b);
      }
      return sorts.lastModifiedDesc(a, b);
    },
    nameAsc: function (a, b) {
      return a.definition().name.localeCompare(b.definition().name);
    },
    nameDesc: function (a, b) {
      return sorts.nameAsc(b, a);
    },
    descriptionAsc: function (a, b) {
      return a.definition().description.localeCompare(b.definition().description);
    },
    descriptionDesc: function (a, b) {
      return sorts.descriptionAsc(b, a);
    },
    typeAsc: function (a, b) {
      return a.definition().type.localeCompare(b.definition().type);
    },
    typeDesc: function (a, b) {
      return sorts.typeAsc(b, a);
    },
    ownerAsc: function (a, b) {
      return a.definition().owner.localeCompare(b.definition().owner);
    },
    ownerDesc: function (a, b) {
      return sorts.ownerAsc(b, a);
    },
    lastModifiedAsc: function (a, b) {
      return a.definition().last_modified_ts - b.definition().last_modified_ts;
    },
    lastModifiedDesc: function (a, b) {
      return sorts.lastModifiedAsc(b, a);
    }
  };

  /**
   *
   * @param {Object} options
   * @param {ApiHelper} options.apiHelper
   * @param {Object} options.definition
   * @param {Function} options.activeEntry - The observable keeping track of the current open directory
   * @param {Function} options.trashEntry - The observable keeping track of the trash directory
   * @param {HueFolder} options.parent
   * @param {string} options.app - Currently only 'documents' is supported
   * @param {string} options.user
   *
   * @constructor
   */
  function HueFileEntry (options) {
    var self = this;
    self.activeEntry = options.activeEntry;
    self.trashEntry = options.trashEntry;
    self.parent = options.parent;
    self.definition = ko.observable(options.definition);
    self.apiHelper = options.apiHelper;
    self.app = options.app;
    self.user = options.user;
    self.superuser = options.superuser;
    self.serverTypeFilter = options.serverTypeFilter || ko.observable({ type: 'all' });
    self.statsVisible = ko.observable(false);
    self.highlight = ko.observable(false);

    self.document = ko.observable();
    self.selectedDocsWithDependents = ko.observable([]);
    self.importedDocSummary = ko.observable();
    self.showTable = ko.observable();
    self.entries = ko.observableArray([]);

    // Filter is only used in the assist panel at the moment
    self.isFilterVisible = ko.observable(false);
    self.filter = ko.observable('').extend({ rateLimit: 400 });

    self.typeFilter = options.typeFilter || ko.observable(DOCUMENT_TYPES[0]); // First one is always 'all'

    self.isFilterVisible.subscribe(function (newValue) {
      if (!newValue && self.filter()) {
        self.filter('');
      }
    });

    self.filteredEntries = ko.pureComputed(function () {
      var filter = self.filter().toLowerCase();
      var typeFilter = self.typeFilter().type;
      if (filter || typeFilter !== 'all') {
        return self.entries().filter(function (entry) {
          var entryType = entry.definition().type;
          return (typeFilter === 'all' || entryType === typeFilter || entryType === 'directory')
            && (!filter || entry.definition().name.toLowerCase().indexOf(filter) !== -1 ||
            (HUE_I18n.documentType[entryType] && HUE_I18n.documentType[entryType].toLowerCase().indexOf(filter) !== -1) ||
            entry.definition().description.toLowerCase().indexOf(filter) !== -1);
        })
      }
      return self.entries();
    });

    self.getSelectedDocsWithDependents = function() {
      self.selectedDocsWithDependents([]);
      var uuids = self.selectedEntries().map(function(entry) {
        return entry.definition().uuid;
{'fraction_non_alphanumeric': 0.13530198580100833, 'fraction_numerical': 0.0038069760263401585, 'mean_word_length': 3.044943820224719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2370364', 'n_tokens_mistral': 2848, 'n_tokens_neox': 2797, 'n_words': 747}