<commit_before>import stringify from 'stabilize'
import mapValues from 'lodash/mapValues'

export function prepareStudentForSave(initialStudent) {
	// we're going to use object rest/spread to "omit" values from the objects

	let {
		areas: _areas,
		canGraduate: _can,
		fulfilled: _fulfilled,
		...student
	} = initialStudent

	student.schedules = mapValues(
		student.schedules,
		({courses: _courses, conflicts: _conflicts, hasConflict: _has, ...s}) =>
			s,
	)

	return student
}

export function encodeStudent(student) {
	return encodeURIComponent(stringify(prepareStudentForSave(student)))
}<commit_msg>add flow types to encodeStudent<commit_after>// @flow

import stringify from 'stabilize'
import mapValues from 'lodash/mapValues'

import type {HydratedStudentType} from '@gob/object-student'

export function prepareStudentForSave(initialStudent: HydratedStudentType) {
	// we're going to use object rest/spread to "omit" values from the objects

	let {
		areas: _areas,
		canGraduate: _can,
		fulfilled: _fulfilled,
		...student
	} = initialStudent

	student.schedules = mapValues(
		student.schedules,
		({courses: _courses, conflicts: _conflicts, hasConflict: _has, ...s}) =>
			s,
	)

	return student
}

export function encodeStudent(student: HydratedStudentType) {
	return encodeURIComponent(stringify(prepareStudentForSave(student)))
}
{'fraction_non_alphanumeric': 0.10074074074074074, 'fraction_numerical': 0.0, 'mean_word_length': 5.197247706422019, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7548336', 'n_tokens_mistral': 451, 'n_tokens_neox': 419, 'n_words': 113}