Got a question about the GQL query tool: How diffi...
# ask-community
k
Got a question about the GQL query tool: How difficult would it be to query the execution time of all task instances in a given flow with a given identifier?
k
Hi @kevin, you can’t entire do this in graphQL. You’d need to use graphQL then bring it in to processing in Python with something like this:
Copy code
query {
  task_run(where: { flow_run: { flow_id: { _eq: $flowId } } } ) {
    id
    start_time
    end_time
  }
}
and then :
Copy code
runs = client.graphql(query, variables=dict(flowId="<<flow_id>>"))

task_runs = []
for run in runs["data"]:
  task_runs.append({ "id": run["id"], "duration": run["end_time"] - run["start_time"] })

# now you can do stuff with those durations
avg_duration = sum(r["duration"] for r in task_runs) / len(task_runs)
k
thanks for the help kevin!
👍 1