<commit_before>var _ = require('lodash')
var React = require('react')

var AreaOfStudy = require('./areaOfStudy')
var StudentSummary = require('./studentSummary')

var asianStudies = require('../../mockups/demo_major')
var computerScience = require('../../mockups/demo_csci_major')
var getCourses = require('../helpers/getCourses').getCourses

var AsianStudies = React.createClass({
	load: function() {
		asianStudies(this.props).bind(this).then(function(result) {
			console.log('calculated asian studies graduation possibility', result)
			this.setState({
				result: JSON.stringify(result, undefined, 2)
			})
		})
	},
	getInitialState: function() {
		return {
			status: {}
		}
	},
	componentWillReceiveProps: function() {
		this.load()
	},
	componentDidMount: function() {
		this.load()
	},
	render: function() {
		return React.DOM.article(
			{className: 'area-of-study'},
			React.DOM.pre(null, this.state.result)
		)
	}
})

var ComputerScience = React.createClass({
	load: function() {
		computerScience(this.props).bind(this).then(function(result) {
			console.log('calculated comp sci graduation possibility', result)
			this.setState({
				result: JSON.stringify(result, undefined, 2)
			})
		})
	},
	getInitialState: function() {
		return {
			status: {}
		}
	},
	componentWillReceiveProps: function() {
		this.load()
	},
	componentDidMount: function() {
		this.load()
	},
	render: function() {
		return React.DOM.article(
			{className: 'area-of-study'},
			React.DOM.pre(null, this.state.result)
		)
	}
})

var GraduationStatus = React.createClass({
	putActiveCoursesIntoState: function() {
		var clbids = _.chain(this.props.schedules.val())
			.filter('active')
			.pluck('clbids')
			.flatten()
			.uniq()
			.value()

		var self = this
		getCourses(clbids).then(function(courses) {
			console.log('retrieved ' + courses.length + ' courses for graduation-status')
			self.setState({
				courses: courses
			})
		})
	},
	getInitialState: function() {
		return {
			courses: []
		}
	},
	componentWillReceiveProps: function() {
		this.putActiveCoursesIntoState()
	},
	componentDidMount: function() {
		this.putActiveCoursesIntoState()
	},
	render: function() {
		// console.log('graduation-status render')

		// Get areas of study
		var areasOfStudy = _.groupBy(this.props.studies.val(), 'type')
		areasOfStudy = _.mapValues(areasOfStudy, function(areas) {
			return _.map(areas, function(area) {
				area.key = area.id
				area.courses = this.state.courses
				return AreaOfStudy(area)
			}, this)
		}, this)

		return React.DOM.section({className: 'graduation-status'},
			StudentSummary(_.merge(this.props, {courses: this.state.courses})),
			React.DOM.section({id: 'degrees'},
				React.DOM.header({className: 'area-type-heading'},
					React.DOM.h1(null, 'Degrees'),
					React.DOM.button({className: 'add-area-of-study', title: 'Add Degree'})
				),
				areasOfStudy.degree
			),
			React.DOM.section({id: 'majors'},
				React.DOM.header({className: 'area-type-heading'},
					React.DOM.h1(null, 'Majors'),
					React.DOM.button({className: 'add-area-of-study', title: 'Add Major'})
				),
				areasOfStudy.major
			),
			React.DOM.section({id: 'concentrations'},
				React.DOM.header({className: 'area-type-heading'},
					React.DOM.h1(null, 'Concentrations'),
					React.DOM.button({className: 'add-area-of-study', title: 'Add Concentration'})
				),<commit_msg>Create the student object once and pass it to the areas, too<commit_after>var _ = require('lodash')
var React = require('react')

var AreaOfStudy = require('./areaOfStudy')
var StudentSummary = require('./studentSummary')

var asianStudies = require('../../mockups/demo_major')
var computerScience = require('../../mockups/demo_csci_major')
var getCourses = require('../helpers/getCourses').getCourses

var AsianStudies = React.createClass({
	load: function() {
		asianStudies(this.props).bind(this).then(function(result) {
			console.log('calculated asian studies graduation possibility', result)
			this.setState({
				result: JSON.stringify(result, undefined, 2)
			})
		})
	},
	getInitialState: function() {
		return {
			status: {}
		}
	},
	componentWillReceiveProps: function() {
		this.load()
	},
	componentDidMount: function() {
		this.load()
	},
	render: function() {
		return React.DOM.article(
			{className: 'area-of-study'},
			React.DOM.pre(null, this.state.result)
		)
	}
})

var ComputerScience = React.createClass({
	load: function() {
		computerScience(this.props).bind(this).then(function(result) {
			console.log('calculated comp sci graduation possibility', result)
			this.setState({
				result: JSON.stringify(result, undefined, 2)
			})
		})
	},
	getInitialState: function() {
		return {
			status: {}
		}
	},
	componentWillReceiveProps: function() {
		this.load()
	},
	componentDidMount: function() {
		this.load()
	},
	render: function() {
		return React.DOM.article(
			{className: 'area-of-study'},
			React.DOM.pre(null, this.state.result)
		)
	}
})

var GraduationStatus = React.createClass({
	putActiveCoursesIntoState: function() {
		var clbids = _.chain(this.props.schedules.val())
			.filter('active')
			.pluck('clbids')
			.flatten()
			.uniq()
			.value()

		var self = this
		getCourses(clbids).then(function(courses) {
			console.log('retrieved ' + courses.length + ' courses for graduation-status')
			self.setState({
				courses: courses
			})
		})
	},
	getInitialState: function() {
		return {
			courses: []
		}
	},
	componentWillReceiveProps: function() {
		this.putActiveCoursesIntoState()
	},
	componentDidMount: function() {
		this.putActiveCoursesIntoState()
	},
	render: function() {
		// console.log('graduation-status render')

		var student = _.merge(this.props, {courses: this.state.courses})

		// Get areas of study
		var areasOfStudy = _.groupBy(this.props.studies.val(), 'type')
		areasOfStudy = _.mapValues(areasOfStudy, function(areas) {
			return _.map(areas, function(area) {
				area.key = area.id
				area.student = student
				return AreaOfStudy(area)
			}, this)
		}, this)

		return React.DOM.section({className: 'graduation-status'},
			StudentSummary(student),
			React.DOM.section({id: 'degrees'},
				React.DOM.header({className: 'area-type-heading'},
					React.DOM.h1(null, 'Degrees'),
					React.DOM.button({className: 'add-area-of-study', title: 'Add Degree'})
				),
				areasOfStudy.degree
			),
			React.DOM.section({id: 'majors'},
				React.DOM.header({className: 'area-type-heading'},
					React.DOM.h1(null, 'Majors'),
					React.DOM.button({className: 'add-area-of-study', title: 'Add Major'})
				),
				areasOfStudy.major
			),
			React.DOM.section({id: 'concentrations'},
				React.DOM.header({className: 'area-type-heading'},
					React.DOM.h1(null, 'Concentrations'),
					React.DOM.button({className: 'add-area-of-study', title: 'Add Concentration'})
				),
{'fraction_non_alphanumeric': 0.16581221620038084, 'fraction_numerical': 0.0014647722279185586, 'mean_word_length': 3.937093275488069, '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': '3082850', 'n_tokens_mistral': 2663, 'n_tokens_neox': 2300, 'n_words': 398}