<commit_before>'use strict';

import * as _ from 'lodash'

function onlyQuarterCreditCoursesCanBePassFail(course) {
	// NOTE: Because we can't check this (don't know p/f data), we return true
	// for everything.
	return true
}

var hasGenEd = _.curry(function(gened, course) {
	return _.contains(course.gereqs, gened)
})

var hasFOL = function(course) {
	return _.any(course.gereqs,
		req => req.substr(0,3) === 'FOL')
}

function countGeneds(courses, gened) {
	let uniqed = _.uniq(courses, 'crsid');
	if (gened === 'FOL')
		return _.size(_.filter(uniqed, hasFOL))
	return _.size(_.filter(uniqed, hasGenEd(gened)))
}

function getDepartments(courses) {
	return _.chain(courses).pluck('depts').flatten().uniq().value()
}

function acrossAtLeastTwoDepartments(courses) {
	var depts = getDepartments(courses)

	return _.size(depts) >= 2
}

function checkThatNCoursesSpanTwoDepartments(courses, geneds, genedToCheck, n=2) {
	// Input: courses-array of courses. geneds-['ALS-A', 'ALS-L']. genedToCheck-'ALS-A'
	// XXX,YYY - N courses, from different departments
	var coursesOne = _.filter(courses, hasGenEd(geneds[0]))
	var coursesTwo = _.filter(courses, hasGenEd(geneds[1]))

	var allCourses = _.uniq(coursesOne.concat(coursesTwo), 'crsid')
	var coversTwoDepartments = acrossAtLeastTwoDepartments(allCourses)

	return _.all([
		countGeneds(courses, genedToCheck) >= 1,
		_.size(allCourses) >= n,
		coversTwoDepartments
	])
}

export {
	onlyQuarterCreditCoursesCanBePassFail,
	hasGenEd,
	hasFOL,
	countGeneds,
	getDepartments,
	acrossAtLeastTwoDepartments,
	checkThatNCoursesSpanTwoDepartments
}<commit_msg>Make/export function to check if a course is an intercollegiate sport<commit_after>'use strict';

import * as _ from 'lodash'

function onlyQuarterCreditCoursesCanBePassFail(course) {
	// NOTE: Because we can't check this (don't know p/f data), we return true
	// for everything.
	return true
}

var hasGenEd = _.curry(function(gened, course) {
	return _.contains(course.gereqs, gened)
})

var hasFOL = function(course) {
	return _.any(course.gereqs,
		req => req.substr(0,3) === 'FOL')
}

function countGeneds(courses, gened) {
	let uniqed = _.uniq(courses, 'crsid');
	if (gened === 'FOL')
		return _.size(_.filter(uniqed, hasFOL))
	return _.size(_.filter(uniqed, hasGenEd(gened)))
}

function getDepartments(courses) {
	return _.chain(courses).pluck('depts').flatten().uniq().value()
}

function acrossAtLeastTwoDepartments(courses) {
	var depts = getDepartments(courses)

	return _.size(depts) >= 2
}

function checkThatNCoursesSpanTwoDepartments(courses, geneds, genedToCheck, n=2) {
	// Input: courses-array of courses. geneds-['ALS-A', 'ALS-L']. genedToCheck-'ALS-A'
	// XXX,YYY - N courses, from different departments
	var coursesOne = _.filter(courses, hasGenEd(geneds[0]))
	var coursesTwo = _.filter(courses, hasGenEd(geneds[1]))

	var allCourses = _.uniq(coursesOne.concat(coursesTwo), 'crsid')
	var coversTwoDepartments = acrossAtLeastTwoDepartments(allCourses)

	return _.all([
		countGeneds(courses, genedToCheck) >= 1,
		_.size(allCourses) >= n,
		coversTwoDepartments
	])
}

function isIntercollegiateSport(course) {
	// Only one SPM course credit may be earned by students as a result of
	// participation in an approved intercollegiate sport. This credit must be
	// entered as Exercise Science 171-194 at the registration preceding the
	// sport/participation term.
	let result = hasDeptNumBetween({dept: 'ESTH', start: 171, end: 194}, course)
	return result
}

export {
	onlyQuarterCreditCoursesCanBePassFail,
	hasGenEd,
	hasFOL,
	countGeneds,
	getDepartments,
	acrossAtLeastTwoDepartments,
	checkThatNCoursesSpanTwoDepartments
	isIntercollegiateSport
}
{'fraction_non_alphanumeric': 0.12683723462166577, 'fraction_numerical': 0.007076755579749592, 'mean_word_length': 5.369150779896014, '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': '5090226', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1308, 'n_words': 294}