<commit_before>import filter from 'lodash/collection/filter'
import size from 'lodash/collection/size'
import map from 'lodash/collection/map'

import checkStudentAgainstArea from './check-student-against-area'
import countCredits from '../area-tools/count-credits'


/**
 * Checks a student objects graduation possibilities against all of its areas of study.
 *
 * @param {Student} student - the student object
 * @returns {Promise} - the promise of knowledge
 * @promise GraduatabilityPromise
 * @fulfill {Object} - The details of the students graduation prospects.
 *    {boolean} graduatability
 *    {object} areaDetails
 */
export default async function checkStudentGraduatability(student) {
	const areaPromises = map(
		student.studies,
		area => checkStudentAgainstArea(student, area))

	const areaDetails = await Promise.all(areaPromises)

	const goodAreas = filter(areaDetails, {computed: true})
	const allAreasPass = (size(goodAreas) === size(areaDetails))

	const hasEnoughCredits = (countCredits(await student.courses) >= student.creditsNeeded)

	const graduatability = (allAreasPass && hasEnoughCredits)

	return {
		canGraduate: graduatability,
		details: areaDetails,
	}<commit_msg>fix checkStudentGraduatability to use getStudentCourses<commit_after>import filter from 'lodash/collection/filter'
import size from 'lodash/collection/size'
import map from 'lodash/collection/map'

import checkStudentAgainstArea from './check-student-against-area'
import countCredits from '../area-tools/count-credits'
import getStudentCourses from './get-student-courses'


/**
 * Checks a student objects graduation possibilities against all of its areas of study.
 *
 * @param {Student} student - the student object
 * @returns {Promise} - the promise of knowledge
 * @promise GraduatabilityPromise
 * @fulfill {Object} - The details of the students graduation prospects.
 *    {boolean} graduatability
 *    {object} areaDetails
 */
export default async function checkStudentGraduatability(student) {
	const areaPromises = map(student.studies,
		area => checkStudentAgainstArea(student, area))

	const areaDetails = await Promise.all(areaPromises)

	const goodAreas = filter(areaDetails, {computed: true})
	const allAreasPass = (size(goodAreas) === size(areaDetails))

	const currentCredits = countCredits(await getStudentCourses(student))
	const hasEnoughCredits = (currentCredits >= student.creditsNeeded)

	const graduatability = (allAreasPass && hasEnoughCredits)

	return {
		canGraduate: graduatability,
		details: areaDetails,
	}
{'fraction_non_alphanumeric': 0.09452540370224498, 'fraction_numerical': 0.0, 'mean_word_length': 5.414141414141414, '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': '814239', 'n_tokens_mistral': 751, 'n_tokens_neox': 722, 'n_words': 208}