Statistics over the API

Hello everyone,
I want to fetch some statistics automatically. I already checked the API but was not able to find something that would solve this. Maybe you have an idea on how to achieve this:

I want to fetch regularly (weekly or daily) the number of:

  1. Test cases created
  2. Test cases removed
  3. Test cases changed
  4. Test runs executed
  5. Test runs that failed
  6. Test runs that were successful.

I would like to have all those numbers in total for the whole project, and split by Tester.

  1. and 2 I might be able to get, by comparing the numbers to the counts yesterday. But This would fail if I want to sort by user.

Thanks for your help.
Have a nice day.

Aiko

Hi Aiko,

Here is an API request which should work for your use case - a few notes:

  • you need to replace the comments in my example with your actual values (cutoff date and project id)
  • the user id’s returned by the API need to be resolved separately to names (see below)

POST to /api/v1/data-batch

{
    "steps": [
        {
            "op": "analyze",
            "as": "tcs_created",
            "params": {
                "tables": { "tc": "testcases" },
                "aggr": { "tc": { "id": "count" } },
                "filter": { "tc.created_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */ } },
                "projectId": /* your project id e.g. 1 */
            }
        },
        {
            "op": "analyze",
            "as": "tcs_created_by_user",
            "params": {
                "tables": { "tc": "testcases" },
                "aggr": { "tc": { "id": "count" } },
                "group": { "tc": "created_by" },
                "filter": { "tc.created_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */} },
                "projectId": /* your project id e.g. 1 */
            }
        },
        {
            "op": "analyze",
            "as": "tcs_modified",
            "params": {
                "tables": { "tc": "testcases" },
                "aggr": { "tc": { "id": "count" } },
                "filter": { "tc.modified_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */} },
                "projectId": /* your project id e.g. 1 */
            }
        },
        {
            "op": "analyze",
            "as": "tcs_modified_by",
            "params": {
                "tables": { "tc": "testcases" },
                "aggr": { "tc": { "id": "count" } },
                "group": { "tc": "modified_by" },
                "filter": { "tc.modified_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */} },
                "projectId": /* your project id e.g. 1 */
            }
        },
        {
            "op": "analyze",
            "as": "tcs_deleted",
            "params": {
                "tables": { "tc": "testcases" },
                "aggr": { "tc": { "id": "count" } },
                "filter": { "tc.deleted_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */} },
                "projectId": /* your project id e.g. 1 */,
                "includeDeleted": true
            }
        },
        {
            "op": "analyze",
            "as": "tcs_deleted_by",
            "params": {
                "tables": { "tc": "testcases" },
                "aggr": { "tc": { "id": "count" } },
                "group": { "tc": "deleted_by" },
                "filter": { "tc.deleted_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */} },
                "projectId": /* your project id e.g. 1 */,
                "includeDeleted": true
            }
        },
        {
            "op": "analyze",
            "as": "results",
            "params": {
                "tables": { "trtc": "testcase_testrun_map" },
                "aggr": { "trtc": { "testcase_id": "count" } },
                "filter": { "trtc.result_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */} },
                "projectId": /* your project id e.g. 1 */
            }
        },
        {
            "op": "analyze",
            "as": "results_by_user_and_status",
            "params": {
                "tables": { "trtc": "testcase_testrun_map" },
                "aggr": { "trtc": { "testcase_id": "count" } },
                "group": { "trtc": ["result_by", "result_status"] },
                "filter": { "trtc.result_at": { "op": "gt", "value": /* your cutoff date e.g. "2024-04-01T00:00:00.000Z" */} },
                "projectId": /* your project id e.g. 1 */
            }
        }
    ]
}

to resolve user ids:
(insert the ids you need to resolve below)

POST to /api/v1/user-profile/find


{
    "filter": {"user_id": [1234, 12345, ...]}
}

Regards,
Michael

Thank you Michael, that is perfect!
I will try to integrate this and come back, if I have issues!

Thanks again!