<commit_before>// 3rd party modules
const mongoose = require('mongoose');
const _ = require('lodash');
const QueryPlugin = require('mongoose-query');

// application modules
const ResourceAllocationPlugin = require('./plugins/resource-allocator');
const validators = require('../tools/validators');
// Implementation
const {tagsValidator, appsValidator, metaValidator} = validators;
const {Schema} = mongoose;
const {Types} = Schema;
const {ObjectId} = Types;

/**
 * Resource schema
 */
const ResourceSchema = new Schema({
  name: {type: String}, // Resource Name
  type: { // Resource type
    type: String,
    required: true,
    enum: [
      'system',
      'dut',
      'instrument',
      'accessories',
      'computer',
      'room'
    ]},
  item: {
    model: {type: String},
    ref: {type: ObjectId, ref: 'Item'}
  },
  status: {
    value: {
      type: String,
      enum: [
        'active',
        'maintenance',
        'storage',
        'broken'
      ],
      default: 'active'
    },
    note: {
      type: String // e.g. notes why it's in maintenance
    },
    availability: { // @todo fetch this information from loans details
      type: String,
      enum: ['free', 'reserved']
    },
    time: {type: Date, default: Date.now}
  },
  cre: {
    user: {type: ObjectId, ref: 'User'},
    time: {type: Date, default: Date.now}
  },
  mod: {
    user: {type: ObjectId, ref: 'User'},
    timestamp: {type: Date, default: Date.now}
  },
  ownership: {
    corporation: {type: String},
    unit: {type: String},<commit_msg>add unique barcode for resource model (#498)<commit_after>// 3rd party modules
const mongoose = require('mongoose');
const _ = require('lodash');
const QueryPlugin = require('mongoose-query');

// application modules
const ResourceAllocationPlugin = require('./plugins/resource-allocator');
const validators = require('../tools/validators');
// Implementation
const {tagsValidator, appsValidator, metaValidator} = validators;
const {Schema} = mongoose;
const {Types} = Schema;
const {ObjectId} = Types;

/**
 * Resource schema
 */
const ResourceSchema = new Schema({
  name: {type: String}, // Resource Name
  type: { // Resource type
    type: String,
    required: true,
    enum: [
      'system',
      'dut',
      'instrument',
      'accessories',
      'computer',
      'room'
    ]},
  item: {
    model: {type: String},
    ref: {type: ObjectId, ref: 'Item'}
  },
  barcode: {type: String, unique: true, sparse: true},
  status: {
    value: {
      type: String,
      enum: [
        'active',
        'maintenance',
        'storage',
        'broken'
      ],
      default: 'active'
    },
    note: {
      type: String // e.g. notes why it's in maintenance
    },
    availability: { // @todo fetch this information from loans details
      type: String,
      enum: ['free', 'reserved']
    },
    time: {type: Date, default: Date.now}
  },
  cre: {
    user: {type: ObjectId, ref: 'User'},
    time: {type: Date, default: Date.now}
  },
  mod: {
    user: {type: ObjectId, ref: 'User'},
    timestamp: {type: Date, default: Date.now}
  },
  ownership: {
    corporation: {type: String},
    unit: {type: String},
{'fraction_non_alphanumeric': 0.15670232850849591, 'fraction_numerical': 0.0015733165512901196, 'mean_word_length': 2.74, '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': '4854744', 'n_tokens_mistral': 998, 'n_tokens_neox': 988, 'n_words': 284}