Skip to content

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Gbury
Copy link
Contributor

@Gbury Gbury commented Apr 3, 2025

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.

Comment on lines 221 to 228
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
Copy link
Contributor

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

Copy link
Contributor Author

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).

@Gbury
Copy link
Contributor Author

Gbury commented Apr 17, 2025

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 HACKING.md), in the future we may automate the test db creation, ^^

@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, :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants