Skip to content

Commit 0b63d52

Browse files
committed
Performance telemetry API
1 parent ed6604a commit 0b63d52

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tcms/telemetry/api.py

+37
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,40 @@ def _get_count_for(test_executions):
247247
.annotate(count=Count("case_id"))
248248
.order_by("case_id")
249249
)
250+
251+
252+
@http_basic_auth_login_required
253+
@rpc_method(name="Testing.performance")
254+
def performance_telemetry(query=None):
255+
256+
if query is None:
257+
query = {}
258+
259+
executions = (
260+
TestExecution.objects.filter(**query)
261+
# count only execution which are finished
262+
.exclude(status__weight=0)
263+
.order_by("run_id")
264+
.values("assignee_id", "run_id")
265+
)
266+
267+
result = {}
268+
run_id = 0
269+
for execution in executions:
270+
if run_id == 0:
271+
run_id = execution["run_id"]
272+
273+
assignee_count = {}
274+
assignee = execution["assignee_id"]
275+
if assignee in assignee_count:
276+
assignee_count[assignee] = assignee_count[assignee] + 1
277+
else:
278+
assignee_count[assignee] = 1
279+
280+
if execution["run_id"] != run_id:
281+
result[run_id] = assignee_count
282+
283+
assignee_count = {}
284+
run_id = execution["run_id"]
285+
286+
return result

0 commit comments

Comments
 (0)