<commit_before>'use strict';

import * as _ from 'lodash'

import uuid from '../helpers/uuid.es6'
import randomChar from '../helpers/randomChar.es6'
import emitter from '../helpers/emitter.es6'
import db from '../helpers/db.es6'

import ScheduleSet from './scheduleSet.es6'
import StudySet from './studySet.es6'

import * as demoStudent from '../../mockups/demo_student.json'

let Student = (encodedStudent) => {
	encodedStudent = encodedStudent || {}

	let student = {
		id: encodedStudent.id || uuid(),
		name: encodedStudent.name || 'Student ' + randomChar(),
		active: encodedStudent.active || false,

		credits: { needed: 35, has: 0 },

		matriculation: encodedStudent.matriculation || 1894,
		graduation: encodedStudent.graduation || 1898,

		studies: new StudySet(encodedStudent.studies || {}),
		schedules: new ScheduleSet(encodedStudent.schedules || {}),
		overrides: encodedStudent.overrides || [],
		fabrications: encodedStudent.fabrications || [],
	}

	if (encodedStudent.credits)
		student.credits.needed = encodedStudent.credits.needed || student.credits.needed

	Object.observe(student, (changes) => emitter.emit('change'))

	Object.defineProperty(student, 'courses', { get() {
		return this.schedules.activeCourses
	}})<commit_msg>Define students.credits.has as a getter for a live count<commit_after>'use strict';

import * as _ from 'lodash'

import uuid from '../helpers/uuid.es6'
import randomChar from '../helpers/randomChar.es6'
import emitter from '../helpers/emitter.es6'
import db from '../helpers/db.es6'
import countCredits from '../helpers/countCredits.es6'

import ScheduleSet from './scheduleSet.es6'
import StudySet from './studySet.es6'

import * as demoStudent from '../../mockups/demo_student.json'

let Student = (encodedStudent) => {
	encodedStudent = encodedStudent || {}

	let student = {
		id: encodedStudent.id || uuid(),
		name: encodedStudent.name || 'Student ' + randomChar(),
		active: encodedStudent.active || false,

		credits: { needed: 35 },

		matriculation: encodedStudent.matriculation || 1894,
		graduation: encodedStudent.graduation || 1898,

		studies: new StudySet(encodedStudent.studies || {}),
		schedules: new ScheduleSet(encodedStudent.schedules || {}),
		overrides: encodedStudent.overrides || [],
		fabrications: encodedStudent.fabrications || [],
	}

	if (encodedStudent.credits)
		student.credits.needed = encodedStudent.credits.needed || student.credits.needed

	Object.observe(student, (changes) => emitter.emit('change'))

	Object.defineProperty(student, 'courses', { get() {
		return this.schedules.activeCourses
	}})

	Object.defineProperty(student.credits, 'has', { get() {
		return countCredits(student.courses)
	}})
{'fraction_non_alphanumeric': 0.14519731943410275, 'fraction_numerical': 0.012658227848101266, 'mean_word_length': 4.717021276595744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4091937', 'n_tokens_mistral': 875, 'n_tokens_neox': 811, 'n_words': 187}