Skip to content
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

Add functions to Import/Clear/Export the WCIF #52

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

viroulep
Copy link
Contributor

I wanted to create a pull request on top of #46, but it wouldn't let me open it in this repository because the base branch would have been in my fork too.
Therefore this PR contains all the code from #46; the diff will shrink when #46 is merged, but at the moment I would recommend reviewing this by taking a look at the last 3 commits individually, or going to the diff between fixes and import-export-wcif!

I started by implementing the ExportWCIF function, and ran into an expected behavior from nodemon I did not see coming, where emitting a json in a subfolder would trigger a rebuild of the application and reset the connection in the browser.
I worked around this by creating a default OUTPUT_BASE folder, which I told nodemon to ignore through -i outputs.
I have created a dev-server target in the package.json to be able to conveniently run npm run dev-server without having to remember the correct command line every time.

As far as the implementation goes it was quite straightforward, but I did not invest into error checking and the tool will just crash if it can't write the file.

The ImportWCIF function is quite straightforward too, and load a file relative to SCRIPT_BASE.

I also took the liberty of implementing a ClearWCIF function: the name may need to be adjusted, since the purpose is not to reset the whole WCIF but basically provide a "clean" WCIF on top of which the script will run (no assignments, no groups, no unexpected extensions).

It's actually awesome just to make sure anything created by another tool is gone.
If I'm not mistaken there is not such a function even for the WCA website admins; you would have to go into rails' console to clean up the WCIF manually (which I believe I've done several times in the past when some competitions' state got messed up).

Copy link
Collaborator

@timreyn timreyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

.env.DEV Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
functions/wcif.js Outdated Show resolved Hide resolved
functions/wcif.js Outdated Show resolved Hide resolved
functions/wcif.js Outdated Show resolved Hide resolved
functions/wcif.js Outdated Show resolved Hide resolved
functions/wcif.js Outdated Show resolved Hide resolved
functions/wcif.js Outdated Show resolved Hide resolved
outputs/.keep Outdated Show resolved Hide resolved
@viroulep
Copy link
Contributor Author

Thanks for the quick review!

I just pushed some changes, hopefully I did not overlook any of your comments, feel free to close/re-open threads to make sure I did not miss something :)

Copy link
Collaborator

@timreyn timreyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@timreyn timreyn merged commit a710b00 into cubingusa:main Nov 30, 2023
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