From f4444137c8d8496093221d39dca763e2f8f7cca1 Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Sun, 22 Feb 2026 20:00:03 +0100 Subject: [PATCH] Improve output of cache_stats.py --- cache_stats.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cache_stats.py b/cache_stats.py index f36c430..c22d08e 100755 --- a/cache_stats.py +++ b/cache_stats.py @@ -131,9 +131,18 @@ def main(): args.cache_file, len(cache.items), ) + print_cached_items_stats(logger, cache) + print_data_source_info(logger, cache) + logger.info("---") + logger.info("All done.") + sys.exit(0) + + +def print_cached_items_stats(logger: logging.Logger, cache: CachedData) -> None: + """Printout stats about cached items.""" if not cache.items: - logger.info("Nothing to do.") - sys.exit(0) + logger.debug("No items in cache - nothing to do.") + return ts_min, ts_max, error_cnt = get_timestamp_minmax(logger, cache) ts_diff = ts_max - ts_min @@ -142,8 +151,10 @@ def main(): logger.info("Diff timestamp %i", ts_diff) logger.info("Error count: %i", error_cnt) if ts_diff == 0: + logger.info("Cache distribution:") + logger.info("---") logger.info("%s:%s%%", (ts_min, ts_max), 100) - sys.exit(0) + return if ts_diff < 0: raise ValueError("Timestamp diff cannot be less than 0") @@ -162,11 +173,6 @@ def main(): pct = round(value.count / item_cnt * 100, 1) logger.info("%s:%s%%", key, pct) - print_data_source_info(logger, cache) - logger.info("---") - logger.info("All done.") - sys.exit(0) - def print_data_source_info(logger: logging.Logger, cache: CachedData) -> None: """Printout information about data sources."""