<commit_before>var _ = require('@sailshq/lodash');

module.exports = {
  // A virtual "piece type" only used to display a universal manage modal
  // for documents that are commit-ready. No "modified-document" piece is ever
  // really inserted into the database. -Tom
  extend: 'apostrophe-pieces',
  name: 'workflow-document',
  label: 'Document',
  pluralLabel: 'Documents',
  sort: {
    updatedAt: -1
  },
  beforeConstruct: function(self, options) {
    options.addFilters = [
      {
        name: 'modified'
      },
      {
        name: 'submitted'
      },
      {
        name: 'type'
      }
    ].concat(options.addFilters || []);
    options.addFields = [
      {
        name: 'type',
        type: 'select',
        // Patched after all types are known
        choices: []
      }
    ].concat(options.addFields || []);
    // We do not have fully configurable columns for this custom type,
    // but we configure these two so the sorts work
    options.defaultColumns = [
      {
        name: 'updatedAt',
        label: 'Last Edit',
        sort: {
          'updatedAt': -1
        }
      },
      {
        name: 'workflowLastCommitted',
        label: 'Last Commit',
        sort: {
          'workflowLastCommitted.at': -1
        }
      }
    ];
  },
  construct: function(self, options) {
    var superComposeFilters = self.composeFilters;
    self.options.batchOperations = _.filter(self.options.batchOperations, function(operation) {
      // Only operations that make sense here should come through
      return _.includes([ 'submit', 'commit', 'force-export', 'revert-to-live' ], operation.name);
    });
    self.composeFilters = function() {
      // Move trash filter to end of list
      self.options.addFilters = _.filter(self.options.addFilters || [], function(filter) {
        return (filter.name !== 'trash');
      }).concat(_.filter(self.options.addFilters || [], { name: 'trash' }));
      superComposeFilters();<commit_msg>run quiet<commit_after>var _ = require('@sailshq/lodash');

module.exports = {
  // A virtual "piece type" only used to display a universal manage modal
  // for documents that are commit-ready. No "modified-document" piece is ever
  // really inserted into the database. -Tom
  extend: 'apostrophe-pieces',
  name: 'workflow-document',
  label: 'Document',
  pluralLabel: 'Documents',
  sort: {
    updatedAt: -1
  },
  beforeConstruct: function(self, options) {
    options.addFilters = [
      {
        name: 'modified'
      },
      {
        name: 'submitted'
      },
      {
        name: 'type'
      }
    ].concat(options.addFilters || []);
    options.addFields = [
      {
        name: 'type',
        type: 'select',
        // Patched after all types are known
        choices: []
      }
    ].concat(options.addFields || []);
    // To prevent warnings about unarranged fields. We do not actually
    // edit this virtual, read-only piece type
    options.arrangeFields = [
      {
        name: 'type',
        fields: [ 'type' ]
      }
    ].concat(options.arrangeFields || []);
    // We do not have fully configurable columns for this custom type,
    // but we configure these two so the sorts work
    options.defaultColumns = [
      {
        name: 'updatedAt',
        label: 'Last Edit',
        sort: {
          'updatedAt': -1
        }
      },
      {
        name: 'workflowLastCommitted',
        label: 'Last Commit',
        sort: {
          'workflowLastCommitted.at': -1
        }
      }
    ];
  },
  construct: function(self, options) {
    var superComposeFilters = self.composeFilters;
    self.options.batchOperations = _.filter(self.options.batchOperations, function(operation) {
      // Only operations that make sense here should come through
      return _.includes([ 'submit', 'commit', 'force-export', 'revert-to-live' ], operation.name);
    });
    self.composeFilters = function() {
      // Move trash filter to end of list
      self.options.addFilters = _.filter(self.options.addFilters || [], function(filter) {
        return (filter.name !== 'trash');
      }).concat(_.filter(self.options.addFilters || [], { name: 'trash' }));
      superComposeFilters();
{'fraction_non_alphanumeric': 0.13389021479713603, 'fraction_numerical': 0.001431980906921241, 'mean_word_length': 2.266562743569758, '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': '3953770', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1229, 'n_words': 316}