<commit_before>import {
	call,
	put,
	select,
	takeLatest
} from 'redux-saga/effects'

import ScheduleService from '../services/scheduleService'
import schedule from '../util/schedule'
import logger from '../util/logger'
import { SCHEDULE_TTL } from '../AppSettings'

const getSchedule = state => (state.schedule)
const getUserData = state => (state.user)

function* updateSchedule() {
	const { lastUpdated, data, currentTerm } = yield select(getSchedule)
	const { isLoggedIn, profile } = yield select(getUserData)
	const nowTime = new Date().getTime()
	const timeDiff = nowTime - lastUpdated

	if (
		isLoggedIn &&
		profile.classifications.student &&
		(
			(currentTerm && currentTerm.term_code !== 'inactive' && !data) ||
			timeDiff > SCHEDULE_TTL
		)
	) {
		try {
			yield put({ type: 'GET_SCHEDULE_REQUEST' })
			const term = yield call(ScheduleService.FetchTerm)
			if (term) {
				yield put({ type: 'SET_SCHEDULE_TERM', term })

				const scheduleData = yield call(ScheduleService.FetchSchedule, term.term_code)
				if (scheduleData) {
					yield put({ type: 'SET_SCHEDULE', schedule: scheduleData })
					yield put({ type: 'GET_SCHEDULE_SUCCESS' })
				}

				// check for finals
				const parsedScheduleData = schedule.getData(scheduleData)
				const finalsData = schedule.getFinals(parsedScheduleData)
				const finalsArray = []
				Object.keys(finalsData).forEach((day) => {
					if (finalsData[day].length > 0) {
						finalsArray.push({
							day,
							data: finalsData[day]
						})
					}
				})
				if (finalsArray.length > 0) {
					// check if finals are active
					yield put({ type: 'GET_FINALS_REQUEST' })
					try {
						const finalsActive = yield call(ScheduleService.FetchFinals)
						if (finalsActive) {
							yield put({ type: 'SHOW_CARD', id: 'finals' })
						} else {<commit_msg>call updateTutorSession from scheduleSaga<commit_after>import {
	call,
	put,
	select,
	takeLatest
} from 'redux-saga/effects'

import ScheduleService from '../services/scheduleService'
import schedule from '../util/schedule'
import logger from '../util/logger'
import { SCHEDULE_TTL } from '../AppSettings'

const getSchedule = state => (state.schedule)
const getUserData = state => (state.user)

function* updateSchedule() {
	const { lastUpdated, data, currentTerm } = yield select(getSchedule)
	const { isLoggedIn, profile } = yield select(getUserData)
	const nowTime = new Date().getTime()
	const timeDiff = nowTime - lastUpdated

	if (
		isLoggedIn &&
		profile.classifications.student &&
		(
			(currentTerm && currentTerm.term_code !== 'inactive' && !data) ||
			timeDiff > SCHEDULE_TTL
		)
	) {
		try {
			yield put({ type: 'GET_SCHEDULE_REQUEST' })
			const term = yield call(ScheduleService.FetchTerm)
			if (term) {
				yield put({ type: 'SET_SCHEDULE_TERM', term })

				const scheduleData = yield call(ScheduleService.FetchSchedule, term.term_code)
				if (scheduleData) {
					yield put({ type: 'SET_SCHEDULE', schedule: scheduleData })
					yield put({ type: 'GET_SCHEDULE_SUCCESS' })
				}

				yield put({ type: 'UPDATE_TUTOR_SESSIONS' })

				// check for finals
				const parsedScheduleData = schedule.getData(scheduleData)
				const finalsData = schedule.getFinals(parsedScheduleData)
				const finalsArray = []
				Object.keys(finalsData).forEach((day) => {
					if (finalsData[day].length > 0) {
						finalsArray.push({
							day,
							data: finalsData[day]
						})
					}
				})
				if (finalsArray.length > 0) {
					// check if finals are active
					yield put({ type: 'GET_FINALS_REQUEST' })
					try {
						const finalsActive = yield call(ScheduleService.FetchFinals)
						if (finalsActive) {
							yield put({ type: 'SHOW_CARD', id: 'finals' })
						} else {
{'fraction_non_alphanumeric': 0.12425876010781671, 'fraction_numerical': 0.001078167115902965, 'mean_word_length': 3.449640287769784, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7626655', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1165, 'n_words': 285}