Skip to content

Commit

Permalink
Add .csv extension for better experience. (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdilauro authored Sep 21, 2023
1 parent 64afa28 commit 49a5d4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions core/jobs/playtime_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,14 @@ def do_run(self):
email_subject = (
f"Playtime Summaries {formatted_start_date} - {formatted_until_date}"
)
attachment_name = (
f"playtime-summary-{formatted_start_date}-{formatted_until_date}"
)
attachment_extension = "csv"
attachment_name = f"playtime-summary-{formatted_start_date}-{formatted_until_date}.{attachment_extension}"

# Write to a temporary file so we don't overflow the memory
with TemporaryFile(
"w+", prefix=f"playtimereport{formatted_until_date}", suffix="csv"
"w+",
prefix=f"playtimereport{formatted_until_date}",
suffix=attachment_extension,
) as temp:
# Write the data as a CSV
writer = csv.writer(temp)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/jobs/test_playtime_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def test_do_run(self, db: DatabaseTransactionFixture):
receivers=["[email protected]"],
text="",
attachments={
f"playtime-summary-{cutoff}-{until}": ""
f"playtime-summary-{cutoff}-{until}.csv": ""
}, # Mock objects do not write data
)

Expand Down

0 comments on commit 49a5d4b

Please sign in to comment.