Skip to content

Commit 116689c

Browse files
author
Jeny Sadadia
committed
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 <[email protected]>
1 parent e0a8851 commit 116689c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

kcidev/libs/dashboard.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def dashboard_api_post(endpoint, params, use_json, body, max_retries=3):
5959

6060
@_dashboard_request
6161
def dashboard_api_fetch(endpoint, params, use_json, max_retries=3):
62-
return requests.get(endpoint)
62+
return requests.get(endpoint, params=params)
6363

6464

6565
def dashboard_fetch_summary(origin, giturl, branch, commit, arch, use_json):
@@ -120,9 +120,10 @@ def dashboard_fetch_build(build_id, use_json):
120120
return dashboard_api_fetch(endpoint, {}, use_json)
121121

122122

123-
def dashboard_fetch_tree_list(origin, use_json):
123+
def dashboard_fetch_tree_list(origin, use_json, days=7):
124124
params = {
125125
"origin": origin,
126+
"interval_in_days": days,
126127
}
127128
return dashboard_api_fetch("tree-fast", params, use_json)
128129

kcidev/subcommands/results/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,16 @@ def summary(origin, git_folder, giturl, branch, commit, latest, arch, use_json):
9292
help="Select KCIDB origin",
9393
default="maestro",
9494
)
95+
@click.option(
96+
"--days",
97+
help="Provide a period of time in days to get results for",
98+
type=int,
99+
default=7,
100+
)
95101
@results_display_options
96-
def trees(origin, use_json):
102+
def trees(origin, use_json, days):
97103
"""List trees from a give origin."""
98-
cmd_list_trees(origin, use_json)
104+
cmd_list_trees(origin, use_json, days)
99105

100106

101107
@results.command()

kcidev/subcommands/results/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def get_command_summary(command_data):
125125
return inconclusive_cmd, pass_cmd, fail_cmd
126126

127127

128-
def cmd_list_trees(origin, use_json):
129-
trees = dashboard_fetch_tree_list(origin, use_json)
128+
def cmd_list_trees(origin, use_json, days):
129+
trees = dashboard_fetch_tree_list(origin, use_json, days)
130130
if use_json:
131131
kci_msg(json.dumps(list(map(lambda t: create_tree_json(t), trees))))
132132
return

0 commit comments

Comments
 (0)