<commit_before>var keystone = require('keystone'),
	Types = keystone.Field.Types;

// Create model. Additional options allow menu name to be used what auto-generating URLs
var SuccessStory = new keystone.List('Success Story', {
	track: true,
	autokey: { path: 'key', from: 'heading', unique: true },
	map: { name: 'heading' }
});

// Create fields
SuccessStory.add({

	heading: { type: Types.Text, label: 'heading', required: true, initial: true },
	url: { type: Types.Url, label: 'url', noedit: true },
	subHeading: { type: Types.Text, label: 'sub-heading', initial: true },
	content: { type: Types.Html, wysiwyg: true, initial: true },
	image: { type: Types.CloudinaryImage, note: 'needed to display in the sidebar and under other success stories', folder: 'success-stories/', publicID: 'fileName', autoCleanup: true },
	imageScaled: {type: Types.Url, hidden: true }

/* Container for all system fields (add a heading if any are meant to be visible through the admin UI) */
}, {

	// system field to store an appropriate file prefix
	fileName: { type: Types.Text, hidden: true }

});

// Pre Save
SuccessStory.schema.pre('save', function(next) {
	'use strict';

	this.imageScaled = this._.image.thumbnail(168,168,{ quality: 80 });
	this.url = '/success-stories/' + this.key;
<commit_msg>#33 | update success story model<commit_after>var keystone = require('keystone'),
	Types = keystone.Field.Types;

// Create model. Additional options allow menu name to be used what auto-generating URLs
var SuccessStory = new keystone.List('Success Story', {
	track: true,
	autokey: { path: 'key', from: 'heading', unique: true },
	map: { name: 'heading' }
});

// Create fields
SuccessStory.add({

	heading: { type: Types.Text, label: 'heading', required: true, initial: true },
	url: { type: Types.Url, label: 'url', noedit: true },
	subHeading: { type: Types.Text, label: 'sub-heading', initial: true },
	content: { type: Types.Html, wysiwyg: true, initial: true },
	image: { type: Types.CloudinaryImage, note: 'needed to display in the sidebar, success story page, and home page', folder: 'success-stories/', publicID: 'fileName', autoCleanup: true },
	imageFeatured: { type: Types.Url, hidden: true },
	imageSidebar: { type: Types.Url, hidden: true }

/* Container for all system fields (add a heading if any are meant to be visible through the admin UI) */
}, {

	// system field to store an appropriate file prefix
	fileName: { type: Types.Text, hidden: true }

});

SuccessStory.schema.statics.findRandom = function(callback) {

  this.count(function(err, count) {
    if (err) {
      return callback(err);
    }
    var rand = Math.floor(Math.random() * count);
    this.findOne().skip(rand).exec(callback);
  }.bind(this));
 };

// Pre Save
SuccessStory.schema.pre('save', function(next) {
	'use strict';

	this.imageFeatured = this._.image.thumbnail( 168, 168, { quality: 80 } );
	this.imageSidebar = this._.image.thumbnail( 216, 196, { quality: 80 } );
	this.url = '/success-stories/' + this.key;

{'fraction_non_alphanumeric': 0.15005001667222406, 'fraction_numerical': 0.008669556518839614, 'mean_word_length': 4.291005291005291, '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': '1965319', 'n_tokens_mistral': 986, 'n_tokens_neox': 936, 'n_words': 310}