#!/usr/bin/python3

"""
Do daily housekeeping on the database.

This is meant to run shortly after midnight every day.
"""

import configuration
from datastore import Datastore

if __name__ == '__main__':

	print("Connecting to database")
	db = Datastore()
	surveys = db.surveys()

	print("Reading surveys")
	for survey in surveys:
		print(f'Survey: {survey["id"]} ({survey["schema"]})')
		db.set_survey(survey["schema"])

		print("Daily tasks")
		db.run_daily_tasks()

	print("Done")
