Currently, default adjudication and move times are hard-coded in the config.py module. Let's make them editable by the administrator and store the values in the database. So each festival can have its own default times.
I have some options for how to store default times in the database. In a python program, they would be best represented in a dictionary, as shown in the example below:
But to store that dictionary in a database, I need to store it as a JSON object. SQLAlchemy supports storing JSON objects. I could use the example code below:
In my opinion, it's better to keep things in an SQL database in a normalized fashion. Adding in nested dictionaries in a nested field to support a single feature will lead to confusion later on. Performance or functionality will likely be the same in either case so the deciding factor is just to use the database in a consistent way in every case.
When processing a large syllabus, I can use SQLAlchemy's caching ability to avoid going back to the DB for the default times for each item in the syllabus. For example:
# Run an initial query to load multiple rows into the session
festival_id = 1 # Replace with the actual festival ID
stmt = select(Season).where(Season.festival_id == festival_id)
results = session.execute(stmt).scalars().all()
# Access a specific row from the cached results
# without launching a new SQL query to the DB
specific_season_id = 2 # Replace with the actual season ID you want to access
specific_season = session.get(Season, specific_season_id)
This one should be implemented after #64.
Currently, default adjudication and move times are hard-coded in the config.py module. Let's make them editable by the administrator and store the values in the database. So each festival can have its own default times.
I have some options for how to store default times in the database. In a python program, they would be best represented in a dictionary, as shown in the example below:
But to store that dictionary in a database, I need to store it as a JSON object. SQLAlchemy supports storing JSON objects. I could use the example code below:
Or, I could organize the data as a table that contains default times for all festivals:
In my opinion, it's better to keep things in an SQL database in a normalized fashion. Adding in nested dictionaries in a nested field to support a single feature will lead to confusion later on. Performance or functionality will likely be the same in either case so the deciding factor is just to use the database in a consistent way in every case.
When processing a large syllabus, I can use SQLAlchemy's caching ability to avoid going back to the DB for the default times for each item in the syllabus. For example: