Skip to content

Commit 00f37ff

Browse files
committed
Also record the ids of the archives being used
This will allow us to confirm to the competitors which were used at the competition.
1 parent 45d2a35 commit 00f37ff

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

code_submitter/extract_archives.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@ async def async_main(submissions_directory: Path) -> None:
1717
async with database.transaction():
1818
submissions = await utils.get_chosen_submissions(database)
1919

20-
for team, content in submissions.items():
20+
for team, (_, content) in submissions.items():
2121
(submissions_directory / f'{team.upper()}.zip').write_bytes(content)
2222

23+
(submissions_directory / 'summary.txt').write_text(
24+
"".join(
25+
"{}: {}\n".format(team, id_)
26+
for team, (id_, _) in submissions.items()
27+
),
28+
)
29+
2330

2431
def parse_args() -> argparse.Namespace:
2532
parser = argparse.ArgumentParser()

code_submitter/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
from typing import Dict
1+
from typing import Dict, Tuple
22

33
import databases
44
from sqlalchemy.sql import select
55

66
from .tables import Archive, ChoiceHistory
77

88

9-
async def get_chosen_submissions(database: databases.Database) -> Dict[str, bytes]:
9+
async def get_chosen_submissions(
10+
database: databases.Database,
11+
) -> Dict[str, Tuple[int, bytes]]:
1012
"""
1113
Return a mapping of teams to their the chosen archive.
1214
"""
@@ -16,6 +18,7 @@ async def get_chosen_submissions(database: databases.Database) -> Dict[str, byte
1618

1719
rows = await database.fetch_all(
1820
select([
21+
Archive.c.id,
1922
Archive.c.team,
2023
Archive.c.content,
2124
ChoiceHistory.c.created,
@@ -28,4 +31,4 @@ async def get_chosen_submissions(database: databases.Database) -> Dict[str, byte
2831
)
2932

3033
# Rely on later keys replacing earlier occurrences of the same key.
31-
return {x['team']: x['content'] for x in rows}
34+
return {x['team']: (x['id'], x['content']) for x in rows}

tests/tests_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def test_get_chosen_submissions_multiple_chosen(self) -> None:
6767
result = self.await_(utils.get_chosen_submissions(self.database))
6868
self.assertEqual(
6969
{
70-
'SRZ2': b'1111111111',
71-
'ABC': b'8888888888',
70+
'SRZ2': (1111111111, b'1111111111'),
71+
'ABC': (8888888888, b'8888888888'),
7272
},
7373
result,
7474
)

0 commit comments

Comments
 (0)