You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a contest day ends, we want to be able to export the final Markdown translations. One reason is to allow the team leaders to reuse the Notice translation in Day 2. Another reason is for general task archiving purpose.
It is not easy to do this from the UI. As a workaround, @sijie123 came up with a quick script for IOI 2022. The script is posted here as-is for posterity / reference for next years if this functionality is not built yet 😄
two parts: one sql to get the latest version per team per task and dump to csv, and one python3 to take the dumped csv and write into individual files
psql
\c translationdatabase
COPY (
WITH data AS (
SELECT trans_version.*,trans_task.name,trans_country.code2,trans_user.language_id
FROM trans_version
INNER JOIN trans_translation
ON trans_version.translation_id = trans_translation.id
INNER JOIN trans_task
ON trans_translation.task_id = trans_task.id
INNER JOIN trans_user
ON trans_translation.user_id = trans_user.user_ptr_id
INNER JOIN trans_country
ON trans_user.country_id = trans_country.code
)
SELECT a.*
FROM data a
INNER JOIN (
SELECT MAX(id) as maxid
FROM trans_version
GROUP BY translation_id
) AS b ON a.id=b.maxid
) TO '/tmp/test.csv' WITH DELIMITER ',' CSV HEADER;
mkdir -p /tmp/sj
cd /tmp/sj
vim quick.py
import csv
with open('/tmp/test.csv', 'r') as f:
spamreader = csv.DictReader(f, delimiter=',')
for row in spamreader:
with open(f"/tmp/sj/{row['name']}_{row['country_id']}.md", "w") as x:
x.write(row['text'])
python3 quick.py
The text was updated successfully, but these errors were encountered:
After a contest day ends, we want to be able to export the final Markdown translations. One reason is to allow the team leaders to reuse the Notice translation in Day 2. Another reason is for general task archiving purpose.
It is not easy to do this from the UI. As a workaround, @sijie123 came up with a quick script for IOI 2022. The script is posted here as-is for posterity / reference for next years if this functionality is not built yet 😄
The text was updated successfully, but these errors were encountered: