<commit_before>'use strict';
var mongoose = require('mongoose');
var ShortId = require('mongoose-shortid');
var Schema = mongoose.Schema;
var BBPromise = require('bluebird');
var timestamps = require('mongoose-timestamp');
var environments = ['live', 'test', 'dev'];
var mongooseDelete = require('mongoose-delete');

var ExecutionLogEventSchema = new Schema({
  schemaVersion: String,
  //the org that owns this application
  application: {
    type: ShortId,
    ref: 'Application',
    required: 'ExecutionLogEvent must belong to an application',
    index: true
  },
  environment: {
    type: String,
    enum: {
      values: environments,
      message: 'ExecutionLogEvent must belong to a valid environment'
    },
    required: 'ExecutionLogEvent must belong to a valid environment',
    index: true
  },
  moduleName: {
    type: String,
    index: true
  },
  eventId: {
    type: String,
    index: true
  },
  correlationId: {
    type: String,
    index: true
  },
  error: Boolean,
  message: String,
  type: {
    type: String,
    enum: ['LOG', 'ERR', 'MDL', 'EVT'],
    default: 'LOG',
    required: true
  },
  errorStack: [String]
});

ExecutionLogEventSchema.plugin(timestamps);
ExecutionLogEventSchema.plugin(mongooseDelete);

ExecutionLogEventSchema.path('createdAt').index({
  expires: 604800
});

mongoose.model('ExecutionLogEvent', ExecutionLogEventSchema);

var ExecutionLogEvent = mongoose.model('ExecutionLogEvent');
BBPromise.promisifyAll(ExecutionLogEvent);
BBPromise.promisifyAll(ExecutionLogEvent.prototype);
exports.name = 'ExecutionLogEvent';
exports.model = ExecutionLogEvent;<commit_msg>execution log events should only last an hour<commit_after>'use strict';
var mongoose = require('mongoose');
var ShortId = require('mongoose-shortid');
var Schema = mongoose.Schema;
var BBPromise = require('bluebird');
var timestamps = require('mongoose-timestamp');
var environments = ['live', 'test', 'dev'];
var mongooseDelete = require('mongoose-delete');

var ExecutionLogEventSchema = new Schema({
  schemaVersion: String,
  //the org that owns this application
  application: {
    type: ShortId,
    ref: 'Application',
    required: 'ExecutionLogEvent must belong to an application',
    index: true
  },
  environment: {
    type: String,
    enum: {
      values: environments,
      message: 'ExecutionLogEvent must belong to a valid environment'
    },
    required: 'ExecutionLogEvent must belong to a valid environment',
    index: true
  },
  moduleName: {
    type: String,
    index: true
  },
  eventId: {
    type: String,
    index: true
  },
  correlationId: {
    type: String,
    index: true
  },
  error: Boolean,
  message: String,
  type: {
    type: String,
    enum: ['LOG', 'ERR', 'MDL', 'EVT'],
    default: 'LOG',
    required: true
  },
  errorStack: [String]
});

ExecutionLogEventSchema.plugin(timestamps);
ExecutionLogEventSchema.plugin(mongooseDelete);

ExecutionLogEventSchema.path('createdAt').index({
  expires: 3600
});

mongoose.model('ExecutionLogEvent', ExecutionLogEventSchema);

var ExecutionLogEvent = mongoose.model('ExecutionLogEvent');
BBPromise.promisifyAll(ExecutionLogEvent);
BBPromise.promisifyAll(ExecutionLogEvent.prototype);
exports.name = 'ExecutionLogEvent';
exports.model = ExecutionLogEvent;
{'fraction_non_alphanumeric': 0.12454212454212454, 'fraction_numerical': 0.0030525030525030525, 'mean_word_length': 4.461666666666667, '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': '4419723', 'n_tokens_mistral': 979, 'n_tokens_neox': 998, 'n_words': 254}