GUI: Add stats raw mode support

This commit is contained in:
Orsiris de Jong 2024-11-02 13:48:47 +01:00
parent 726ab5ed93
commit 458b1cdad7

View file

@ -152,17 +152,80 @@ def show_stats(statistics: List[dict]) -> None:
for entry in statistics: for entry in statistics:
repo_name = list(entry.keys())[0] repo_name = list(entry.keys())[0]
state = "Success" if entry[repo_name]["result"] else "Failure" state = "Success" if entry[repo_name]["result"] else "Failure"
entry_good = False
# --stats output
try: try:
total_size = BytesConverter(entry[repo_name]["output"]["total_size"]).human total_size = BytesConverter(entry[repo_name]["output"]["total_size"]).human
total_file_count = entry[repo_name]["output"]["total_file_count"] total_file_count = entry[repo_name]["output"]["total_file_count"]
snapshots_count = entry[repo_name]["output"]["snapshots_count"] snapshots_count = entry[repo_name]["output"]["snapshots_count"]
stats_type = "std"
data.append( data.append(
[repo_name, state, total_size, total_file_count, snapshots_count] [repo_name, state, total_size, total_file_count, snapshots_count]
) )
except: entry_good = True
except Exception:
pass
# --stats --mode raw-data output
try:
total_size = BytesConverter(entry[repo_name]["output"]["total_size"]).human
total_uncompressed_size = BytesConverter(
entry[repo_name]["output"]["total_uncompressed_size"]
).human
compression_progress = (
str(round(float(entry[repo_name]["output"]["compression_progress"]), 2))
+ " %"
)
compression_space_saving = (
str(
round(
float(entry[repo_name]["output"]["compression_space_saving"]), 2
)
)
+ " %"
)
compression_ratio = (
str(round(float(entry[repo_name]["output"]["compression_ratio"]), 2))
+ " %"
)
total_blob_count = entry[repo_name]["output"]["total_blob_count"]
snapshots_count = entry[repo_name]["output"]["snapshots_count"]
stats_type = "raw"
data.append(
[
repo_name,
state,
total_size,
total_uncompressed_size,
compression_progress,
compression_space_saving,
compression_ratio,
total_blob_count,
snapshots_count,
]
)
entry_good = True
except Exception:
raise
if not entry_good:
data.append([repo_name, state]) data.append([repo_name, state])
logger.debug(f"Failed statistics for entry: {entry}") logger.debug(f"Failed statistics for entry: {entry}")
if stats_type == "raw":
headings = [
"Repo",
"State state",
"Total size",
"Total uncompressed size",
"Compression progress",
"Compression space savings",
"Compression Ratio",
"Total Blob Count",
"Snapshot Count",
]
else:
headings = [ headings = [
"Repo", "Repo",
"Stat state", "Stat state",
@ -338,10 +401,17 @@ def operations_gui(full_config: dict) -> dict:
key="--STATS--", key="--STATS--",
size=(45, 1), size=(45, 1),
), ),
sg.Button(
_t("operations_gui.stats_raw"),
key="--STATS-RAW--",
size=(45, 1),
visible=False,
),
sg.Button( sg.Button(
_t("operations_gui.show_advanced"), _t("operations_gui.show_advanced"),
key="--ADVANCED--", key="--ADVANCED--",
size=(45, 1), size=(45, 1),
visible=True,
), ),
], ],
[sg.Button(_t("generic.quit"), key="--EXIT--")], [sg.Button(_t("generic.quit"), key="--EXIT--")],
@ -415,9 +485,10 @@ def operations_gui(full_config: dict) -> dict:
"--FORGET--", "--FORGET--",
"--STANDARD-PRUNE--", "--STANDARD-PRUNE--",
"--MAX-PRUNE--", "--MAX-PRUNE--",
"--STATS-RAW--",
): ):
window[button].update(visible=True) window[button].update(visible=True)
window["--ADVANCED--"].update(disabled=True) window["--ADVANCED--"].update(visible=False)
continue continue
if event in ( if event in (
"--HOUSEKEEPING--", "--HOUSEKEEPING--",
@ -432,6 +503,7 @@ def operations_gui(full_config: dict) -> dict:
"--STANDARD-PRUNE--", "--STANDARD-PRUNE--",
"--MAX-PRUNE--", "--MAX-PRUNE--",
"--STATS--", "--STATS--",
"--STATS-RAW--",
): ):
repos = _get_repo_list(values["repo-and-group-list"]) repos = _get_repo_list(values["repo-and-group-list"])
@ -498,6 +570,10 @@ def operations_gui(full_config: dict) -> dict:
operation = "stats" operation = "stats"
op_args = {} op_args = {}
gui_msg = _t("operations_gui.stats") gui_msg = _t("operations_gui.stats")
if event == "--STATS-RAW--":
operation = "stats"
op_args = {"subject": "--mode raw-data"}
gui_msg = _t("operations_gui.stats_raw")
if operation: if operation:
data = gui_thread_runner( data = gui_thread_runner(
None, None,