<commit_before>const mongoose = require('mongoose');
const { nanoid } = require('nanoid');
const _ = require('lodash');
const zlib = require('zlib');

const HomebrewSchema = mongoose.Schema({
	shareId : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
	editId  : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
	title   : { type: String, default: '' },
	text    : { type: String, default: '' },
	textBin : { type: Buffer },

	description : { type: String, default: '' },
	tags        : { type: String, default: '' },
	systems     : [String],
	authors     : [String],
	published   : { type: Boolean, default: false },

	createdAt  : { type: Date, default: Date.now },
	updatedAt  : { type: Date, default: Date.now },
	lastViewed : { type: Date, default: Date.now },
	views      : { type: Number, default: 0 },
	version    : { type: Number, default: 1 }
}, { versionKey: false });


HomebrewSchema.methods.sanatize = function(full=false){
	const brew = this.toJSON();
	delete brew._id;
	delete brew.__v;
	if(full){
		delete brew.editId;
	}
	return brew;
};

HomebrewSchema.methods.increaseView = function(){
	return new Promise((resolve, reject)=>{
		this.lastViewed = new Date();
		this.views = this.views + 1;
		this.text = undefined;
		this.save((err)=>{
			if(err) return reject(err);
			return resolve(this);
		});
	});
};

HomebrewSchema.statics.get = function(query){<commit_msg>Woops!<commit_after>const mongoose = require('mongoose');
const { nanoid } = require('nanoid');
const _ = require('lodash');
const zlib = require('zlib');

const HomebrewSchema = mongoose.Schema({
	shareId : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
	editId  : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
	title   : { type: String, default: '' },
	text    : { type: String, default: '' },
	textBin : { type: Buffer },

	description : { type: String, default: '' },
	tags        : { type: String, default: '' },
	systems     : [String],
	authors     : [String],
	published   : { type: Boolean, default: false },

	createdAt  : { type: Date, default: Date.now },
	updatedAt  : { type: Date, default: Date.now },
	lastViewed : { type: Date, default: Date.now },
	views      : { type: Number, default: 0 },
	version    : { type: Number, default: 1 }
}, { versionKey: false });


HomebrewSchema.methods.sanatize = function(full=false){
	const brew = this.toJSON();
	delete brew._id;
	delete brew.__v;
	if(full){
		delete brew.editId;
	}
	return brew;
};

HomebrewSchema.methods.increaseView = function(){
	return new Promise((resolve, reject)=>{
		this.lastViewed = new Date();
		this.views = this.views + 1;
		const text = this.text;
		this.text = undefined;
		this.save((err)=>{
			if(err) return reject(err);
			return resolve(this);
		});
		this.text = text;
	});
};

HomebrewSchema.statics.get = function(query){
{'fraction_non_alphanumeric': 0.17675213675213675, 'fraction_numerical': 0.004786324786324786, 'mean_word_length': 3.8443708609271523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5076233', 'n_tokens_mistral': 1021, 'n_tokens_neox': 976, 'n_words': 250}