humanize sizes
This commit is contained in:
parent
947ef8e833
commit
8716579508
2 changed files with 99 additions and 1 deletions
|
|
@ -665,10 +665,11 @@ def _execution_status_tone(execution: JobExecution) -> str:
|
|||
|
||||
|
||||
def _stats_summary(execution: JobExecution) -> str:
|
||||
bytes_count = cast(int, execution.bytes_count)
|
||||
return (
|
||||
f"{execution.requests_count} requests"
|
||||
f" • {execution.items_count} items"
|
||||
f" • {execution.bytes_count} bytes"
|
||||
f" • {_format_summary_bytes(bytes_count)}"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -716,6 +717,18 @@ def _format_bytes(value: int) -> str:
|
|||
return f"{value / (1024 * 1024 * 1024):.1f} GB"
|
||||
|
||||
|
||||
def _format_summary_bytes(value: int) -> str:
|
||||
if value == 1:
|
||||
return "1 byte"
|
||||
if value < 1024:
|
||||
return f"{value} bytes"
|
||||
if value < 1024 * 1024:
|
||||
return f"{value / 1024:.1f} KiB"
|
||||
if value < 1024 * 1024 * 1024:
|
||||
return f"{value / (1024 * 1024):.1f} MiB"
|
||||
return f"{value / (1024 * 1024 * 1024):.1f} GiB"
|
||||
|
||||
|
||||
def _humanize_relative_time(reference_time: datetime, target_time: datetime) -> str:
|
||||
delta_seconds = int(round((target_time - reference_time).total_seconds()))
|
||||
if delta_seconds == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue