def print_duration()

in analytics/circleci_analyze.py [0:0]


def print_duration(branch, item_count, name_filter: Callable[[str], bool]) -> None:
    ci_cache = CircleCICache(token=get_circleci_token())
    for pipeline, workflow, job in ci_cache.get_pipeline_jobs(branch=branch, item_count=item_count):
        job_name, job_status, job_number = job['name'], job['status'], job.get("job_number")
        revision = pipeline['vcs']['revision']
        if not name_filter(job_name) or job_number is None:
            continue
        if job_status in ['blocked', 'canceled', 'unauthorized', 'running', 'not_run', 'failing']:
            continue
        started_at = str2date(job['started_at'])
        stopped_at = str2date(job['stopped_at'])
        duration = stopped_at - started_at
        print(f"{job_name} {revision} {duration} {started_at}")