From 932aa36297698fd3d69934428a5293b8afa2d161 Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Thu, 12 Jun 2025 12:24:04 +0530 Subject: [PATCH] Enable `--days` switch for getting tree list For the command `kci-dev results trees`, add `--days` option to provide a period of time in days to get results for. Signed-off-by: Jeny Sadadia --- kcidev/libs/dashboard.py | 3 ++- kcidev/subcommands/results/__init__.py | 10 ++++++++-- kcidev/subcommands/results/parser.py | 5 ++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/kcidev/libs/dashboard.py b/kcidev/libs/dashboard.py index c6e0d69..fa50a19 100644 --- a/kcidev/libs/dashboard.py +++ b/kcidev/libs/dashboard.py @@ -187,9 +187,10 @@ def dashboard_fetch_build(build_id, use_json): return dashboard_api_fetch(endpoint, {}, use_json) -def dashboard_fetch_tree_list(origin, use_json): +def dashboard_fetch_tree_list(origin, use_json, days=7): params = { "origin": origin, + "interval_in_days": days, } logging.info(f"Fetching tree list for origin: {origin}") return dashboard_api_fetch("tree-fast", params, use_json) diff --git a/kcidev/subcommands/results/__init__.py b/kcidev/subcommands/results/__init__.py index 096f849..8871a45 100644 --- a/kcidev/subcommands/results/__init__.py +++ b/kcidev/subcommands/results/__init__.py @@ -92,10 +92,16 @@ def summary(origin, git_folder, giturl, branch, commit, latest, arch, tree, use_ help="Select KCIDB origin", default="maestro", ) +@click.option( + "--days", + help="Provide a period of time in days to get results for", + type=int, + default=7, +) @results_display_options -def trees(origin, use_json): +def trees(origin, use_json, days): """List trees from a give origin.""" - cmd_list_trees(origin, use_json) + cmd_list_trees(origin, use_json, days) @results.command() diff --git a/kcidev/subcommands/results/parser.py b/kcidev/subcommands/results/parser.py index 7ba21a2..3f3fb0d 100644 --- a/kcidev/subcommands/results/parser.py +++ b/kcidev/subcommands/results/parser.py @@ -149,11 +149,10 @@ def get_command_summary(command_data): return inconclusive_cmd, pass_cmd, fail_cmd -def cmd_list_trees(origin, use_json): +def cmd_list_trees(origin, use_json, days): logging.info(f"Listing trees for origin: {origin}") - trees = dashboard_fetch_tree_list(origin, use_json) + trees = dashboard_fetch_tree_list(origin, use_json, days) logging.debug(f"Found {len(trees)} trees") - if use_json: kci_msg(json.dumps(list(map(lambda t: create_tree_json(t), trees)))) return