{"size": 800, "ext": "js", "max_stars_repo_path": "src/utils/download-dining-menu.js", "max_stars_repo_name": "rescenic/Messcat", "max_stars_repo_stars_event_min_datetime": "2021-05-26T23:17:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-26T23:17:39.000Z", "max_issues_repo_path": "src/utils/download-dining-menu.js", "max_issues_repo_name": "rescenic/Messcat", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utils/download-dining-menu.js", "max_forks_repo_name": "rescenic/Messcat", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.5294117647, "max_line_length": 65, "alphanum_fraction": 0.64375}
const {promises: fs} = require('fs')
const { fetchLatestDiningMenu } = require('./fetch-dining-menus')
const { parseMessMenu } = require('./parse-dining-xlsx')

const menu = require('../intents/data/dining_data.json')

const download = async() => {
	const { messMenuFilename } = await fetchLatestDiningMenu()
	const messMenu = await parseMessMenu(messMenuFilename)

	console.log(
		'updated dining menu for ', 
		Object.keys(messMenu.breakfast).filter(t => t != 'timings')[0]
	)

	const keys = Array.from(
		new Set([
			...Object.keys(menu),
			...Object.keys(messMenu),
		])
	)
	keys.forEach(m => {
		messMenu[m] = {
			...(menu[m] || { }),
			...(messMenu[m] || { })
		}
	})

	await fs.writeFile(
		'./src/intents/data/dining_data.json',
		JSON.stringify(messMenu, undefined, '\t')
	)
}
download()