-
Notifications
You must be signed in to change notification settings - Fork 0
Add Import/Export mechanism + code migration from 4ever codebase #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/lib/import.ml
Outdated
let import_event ~st ~subst ~t = | ||
let open Otoml in | ||
let+ name = find_result t get_string ["name"] in | ||
let+ start_date = find_result t Date.of_toml ["start_date"] in | ||
let+ end_date = find_result t Date.of_toml ["end_date"] in | ||
let event_id = Event.create st name ~start_date ~end_date in | ||
let+ t = find_result t Otoml.get_value ["comps"] in | ||
import_comps ~st ~subst ~t ~event_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code have a side effect on the database before we validate everything is okay.
It should be interesting to add a way to either
- rollback them
- parse everything before changing database
- ensure that we can update a partially initialised event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, if you look at how the import function is called in backend/main.ml
you'll see that it is wrapped in a call to State.atomically
which implements a transaction, which means that if the import fails, then the changes will not be comitted.
We can discuss whether the lib/import.ml
module should enforce that call to State.atomically
though (rather than letting its caller handle that).
I fixed the comments and bugs, and added some of the old competitions results, so that it's easy to create a test database (see @But2ene you can take another look if you want (since I've added a few code since you reviewed), but I'll try and merge this soon (this weekend probably) so that the other PRs can be rebased and merged, :) |
Note: this is still WIP.
This adds the possibility to import and export events from files in toml format. Additionally, it adds a bit of logging to make it easier to debug things.