<commit_before>import React from 'react'
import Immutable from 'immutable'
import {oxford, pluralize} from 'humanize-plus'
import plur from 'plur'

import AutosizeInput from 'react-input-autosize'

import studentActions from '../flux/studentActions'

const goodGraduationMessage = "It looks like you'll make it! Just follow the plan, and go over my output with your advisor a few times."
const badGraduationMessage = "You haven't planned everything out yet. Ask your advisor if you need help fitting everything in."

export default class StudentSummary extends React.Component {
	static propTypes = {
		graduatability: React.PropTypes.bool.isRequired,
		student: React.PropTypes.instanceOf(Immutable.Record).isRequired,
	}

	render() {
		// console.log('StudentSummary#render')
		let canGraduate = this.props.graduatability
		let student = this.props.student
		let studies = student.studies

		let name = student.name
		let studentId = this.props.student.id
		let NameEl = (<AutosizeInput className='autosize-input'
			value={name}
			onChange={(ev) => studentActions.updateName(studentId, ev.target.value.trim())} />)

		let has = studies
			.groupBy(s => s.type)
			.map(s => s.size)
			.toObject()

		let degrees = studies.filter(s => s.type === 'degree')
		let majors = studies.filter(s => s.type === 'major')
		let concentrations = studies.filter(s => s.type === 'concentration')
		let emphases = studies.filter(s => s.type === 'emphasis')

		let degreeTitles = oxford(degrees.map(s => s.name).toArray())
		let majorTitles = oxford(majors.map(s => s.name).toArray())
		let concentrationTitles = oxford(concentrations.map(s => s.name).toArray())
		let emphasisTitles = oxford(emphases.map(s => s.name).toArray())

		let degreeWords = pluralize(degrees.size, 'degree')
		let majorWords = pluralize(majors.size, 'major')
		let concentrationWords = pluralize(concentrations.size, 'concentration')
		let emphasisWords = pluralize(emphases.size, 'emphasis', 'emphases')

		let degreeEmphasizer = has.degree === 1 ? 'a ' : ''
		let majorEmphasizer = has.major === 1 ? 'a ' : ''
		let concentrationEmphasizer = has.concentration === 1 ? 'a ' : ''
		let emphasisEmphasizer = has.emphasis === 1 ? 'an ' : ''

		let degreeEl = <span className='area-of-study-list' key='degrees'>{degreeTitles}</span>
		let majorEl = <span className='area-of-study-list' key='majors'>{majorTitles}</span>
		let concentrationEl = <span className='area-of-study-list' key='concentrations'>{concentrationTitles}</span>
		let emphasisEl = <span className='area-of-study-list' key='emphases'>{emphasisTitles}</span>

		// console.log(student.graduation, student.matriculation)

		const graduationEl = (<AutosizeInput
			className='autosize-input'
			value={String(student.graduation)}<commit_msg>switch to const and plur in studentSummary<commit_after>import React from 'react'
import Immutable from 'immutable'
import {oxford} from 'humanize-plus'
import plur from 'plur'

import AutosizeInput from 'react-input-autosize'

import studentActions from '../flux/studentActions'

const goodGraduationMessage = "It looks like you'll make it! Just follow the plan, and go over my output with your advisor a few times."
const badGraduationMessage = "You haven't planned everything out yet. Ask your advisor if you need help fitting everything in."

export default class StudentSummary extends React.Component {
	static propTypes = {
		graduatability: React.PropTypes.bool.isRequired,
		student: React.PropTypes.instanceOf(Immutable.Record).isRequired,
	}

	render() {
		// console.log('StudentSummary#render')
		const canGraduate = this.props.graduatability
		const student = this.props.student
		const studies = student.studies

		const name = student.name
		const studentId = student.id
		const NameEl = (<AutosizeInput className='autosize-input'
			value={name}
			onChange={ev => studentActions.updateName(studentId, ev.target.value.trim())} />)

		const has = studies
			.groupBy(s => s.type)
			.map(s => s.size)
			.toObject()

		const degrees = studies.filter(s => s.type === 'degree')
		const majors = studies.filter(s => s.type === 'major')
		const concentrations = studies.filter(s => s.type === 'concentration')
		const emphases = studies.filter(s => s.type === 'emphasis')

		const degreeTitles = oxford(degrees.map(s => s.name).toArray())
		const majorTitles = oxford(majors.map(s => s.name).toArray())
		const concentrationTitles = oxford(concentrations.map(s => s.name).toArray())
		const emphasisTitles = oxford(emphases.map(s => s.name).toArray())

		const degreeWords = plur('degree', degrees.size)
		const majorWords = plur('major', majors.size)
		const concentrationWords = plur('concentration', concentrations.size)
		const emphasisWords = plur('emphasis', 'emphases', emphases.size)

		const degreeEmphasizer = has.degree === 1 ? 'a ' : ''
		const majorEmphasizer = has.major === 1 ? 'a ' : ''
		const concentrationEmphasizer = has.concentration === 1 ? 'a ' : ''
		const emphasisEmphasizer = has.emphasis === 1 ? 'an ' : ''

		const degreeEl = <span className='area-of-study-list' key='degrees'>{degreeTitles}</span>
		const majorEl = <span className='area-of-study-list' key='majors'>{majorTitles}</span>
		const concentrationEl = <span className='area-of-study-list' key='concentrations'>{concentrationTitles}</span>
		const emphasisEl = <span className='area-of-study-list' key='emphases'>{emphasisTitles}</span>

		// console.log(student.graduation, student.matriculation)

		const graduationEl = (<AutosizeInput
			className='autosize-input'
			value={String(student.graduation)}
{'fraction_non_alphanumeric': 0.13762784855553561, 'fraction_numerical': 0.0014354925533823794, 'mean_word_length': 4.818371607515657, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 43, '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': '6588752', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1717, 'n_words': 426}