Skip to content

Commit 3bee924

Browse files
author
Travis Wrightsman
authored
feat(grzctl,grz-common): show size in inbox listing (#446)
Resolves #388
1 parent 217cf74 commit 3bee924

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

packages/grz-common/src/grz_common/workers/download.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class InboxSubmissionSummary(BaseModel):
243243
state: InboxSubmissionState
244244
oldest_upload: datetime.datetime
245245
newest_upload: datetime.datetime
246+
total_size_bytes: int
246247

247248

248249
def query_submissions(s3_options: S3Options, show_cleaned: bool) -> list[InboxSubmissionSummary]:
@@ -266,6 +267,8 @@ def query_submissions(s3_options: S3Options, show_cleaned: bool) -> list[InboxSu
266267
oldest_object = submission_objects_sorted[next(iter(submission_objects_sorted))]
267268
newest_object = submission_objects_sorted[next(reversed(submission_objects_sorted))]
268269

270+
total_size_bytes = sum(map(itemgetter("Size"), submission_objects))
271+
269272
cleaning_key = f"{submission_id}/cleaning"
270273
cleaned_key = f"{submission_id}/cleaned"
271274
if (cleaning_key in submission_objects_sorted) and (cleaned_key in submission_objects_sorted):
@@ -287,6 +290,7 @@ def query_submissions(s3_options: S3Options, show_cleaned: bool) -> list[InboxSu
287290
state=state,
288291
oldest_upload=oldest_object["LastModified"],
289292
newest_upload=newest_object["LastModified"],
293+
total_size_bytes=total_size_bytes,
290294
)
291295

292296
if state in {InboxSubmissionState.CLEANING, InboxSubmissionState.CLEANED} and (not show_cleaned):

packages/grzctl/src/grzctl/commands/list_submissions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
log = logging.getLogger(__name__)
2424

2525

26+
BYTES_PER_GIGABYTE = 1_000_000_000
27+
28+
2629
def _get_latest_state_str(submission_db: SubmissionDb, submission_id: str) -> str | None:
2730
submission_from_db = submission_db.get_submission(submission_id)
2831
if submission_from_db:
@@ -83,6 +86,7 @@ def _prepare_table(
8386
table.add_column("Database State", no_wrap=True, justify="center", style="green")
8487
table.add_column("Upload Duration", overflow="fold", justify="center")
8588
table.add_column("Newest Upload", overflow="fold")
89+
table.add_column("Size (GB)", justify="center")
8690
for summary in summaries:
8791
match summary.state:
8892
case InboxSubmissionState.INCOMPLETE:
@@ -103,6 +107,7 @@ def _prepare_table(
103107
status_text,
104108
_format_upload_duration(summary.newest_upload - summary.oldest_upload),
105109
summary.newest_upload.astimezone().strftime("%Y-%m-%d %H:%M:%S"),
110+
f"{summary.total_size_bytes / BYTES_PER_GIGABYTE:.1f}",
106111
]
107112
if database_states:
108113
latest_state_txt = _get_latest_state_txt(database_states[summary.submission_id])

0 commit comments

Comments
 (0)