<commit_before>'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var SmallGroupSchema = new Schema({
  classYear: {
    type : Schema.Types.ObjectId,
    ref: 'ClassYear',
    index: true
  },
  name: String,
  enabled: {
    type: Boolean,
    default: true
  },
  students: [{
    type : Schema.Types.ObjectId, ref: 'User',
    index: true
  }],
  dayCodes: [{
    date:Date,
    code:{
      type: String,
      select: false,
      index: true
    },
    bonusDay:{
      type:Boolean,
      default:false,
    },
  }]
});

/*
	Virtuals
*/

SmallGroupSchema
	.virtual('dayCode')
	.get(function(){
		var today = new Date();
		today.setHours(0,0,0,0);
		for (var i = 0;i < this.dayCodes.length;i++){
			if (this.dayCodes[i].date.getTime() === today.getTime()
      && this.dayCodes[i].bonusDay === false){
				return this.dayCodes[i].code;
			}
		}
		return null;
	});

SmallGroupSchema
	.virtual('bonusDayCode')<commit_msg>needed to add code back to queries<commit_after>'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var SmallGroupSchema = new Schema({
  classYear: {
    type : Schema.Types.ObjectId,
    ref: 'ClassYear',
    index: true
  },
  name: String,
  enabled: {
    type: Boolean,
    default: true
  },
  students: [{
    type : Schema.Types.ObjectId, ref: 'User',
    index: true
  }],
  dayCodes: [{
    date:Date,
    code:{
      type: String,
      select: true,
      index: true
    },
    bonusDay:{
      type:Boolean,
      default:false,
    },
  }]
});

/*
	Virtuals
*/

SmallGroupSchema
	.virtual('dayCode')
	.get(function(){
		var today = new Date();
		today.setHours(0,0,0,0);
		for (var i = 0;i < this.dayCodes.length;i++){
			if (this.dayCodes[i].date.getTime() === today.getTime()
      && this.dayCodes[i].bonusDay === false){
				return this.dayCodes[i].code;
			}
		}
		return null;
	});

SmallGroupSchema
	.virtual('bonusDayCode')
{'fraction_non_alphanumeric': 0.16425619834710745, 'fraction_numerical': 0.005165289256198347, 'mean_word_length': 2.7906066536203524, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6707597', 'n_tokens_mistral': 722, 'n_tokens_neox': 710, 'n_words': 143}