def info(broker=None):
    if not broker:
        broker = get_broker()
    term = Terminal()
    broker.ping()
    stat = Stat.get_all(broker=broker)
    # general stats
    clusters = len(stat)
    workers = 0
    reincarnations = 0
    for cluster in stat:
        workers += len(cluster.workers)
        reincarnations += cluster.reincarnations
    # calculate tasks pm and avg exec time
    tasks_per = 0
    per = _('day')
    exec_time = 0
    last_tasks = models.Success.objects.filter(stopped__gte=timezone.now() - timedelta(hours=24))
    tasks_per_day = last_tasks.count()
    if tasks_per_day > 0:
        # average execution time over the last 24 hours
        if not connection.vendor == 'sqlite':
            exec_time = last_tasks.aggregate(time_taken=Sum(F('stopped') - F('started')))
            exec_time = exec_time['time_taken'].total_seconds() / tasks_per_day
        else:
            # can't sum timedeltas on sqlite
            for t in last_tasks:
                exec_time += t.time_taken()
            exec_time = tasks_per_day / exec_time
        # tasks per second/minute/hour/day in the last 24 hours
        if tasks_per_day > 24 * 60 * 60:
            tasks_per = tasks_per_day / (24 * 60 * 60)
            per = _('second')
        elif tasks_per_day > 24 * 60:
            tasks_per = tasks_per_day / (24 * 60)
            per = _('minute')
        elif tasks_per_day > 24:
            tasks_per = tasks_per_day / 24
            per = _('hour')
        else:
            tasks_per = tasks_per_day
    # print to terminal
    print(term.clear_eos())
    col_width = int(term.width / 6)
    print(term.black_on_green(
        term.center(
            _('-- {} {} on {}  --').format(Conf.PREFIX.capitalize(), '.'.join(str(v) for v in VERSION),
                                           broker.info()))))
    print(term.cyan(_('Clusters')) +
          term.move_x(1 * col_width) +
          term.white(str(clusters)) +
          term.move_x(2 * col_width) +
          term.cyan(_('Workers')) +
          term.move_x(3 * col_width) +
          term.white(str(workers)) +
          term.move_x(4 * col_width) +
          term.cyan(_('Restarts')) +
          term.move_x(5 * col_width) +
          term.white(str(reincarnations))
          )
    print(term.cyan(_('Queued')) +
          term.move_x(1 * col_width) +
          term.white(str(broker.queue_size())) +
          term.move_x(2 * col_width) +
          term.cyan(_('Successes')) +
          term.move_x(3 * col_width) +
          term.white(str(models.Success.objects.count())) +
          term.move_x(4 * col_width) +
          term.cyan(_('Failures')) +
          term.move_x(5 * col_width) +
          term.white(str(models.Failure.objects.count()))
          )
    print(term.cyan(_('Schedules')) +
          term.move_x(1 * col_width) +
          term.white(str(models.Schedule.objects.count())) +
          term.move_x(2 * col_width) +
          term.cyan(_('Tasks/{}'.format(per))) +
          term.move_x(3 * col_width) +
          term.white('{0:.2f}'.format(tasks_per)) +
          term.move_x(4 * col_width) +
          term.cyan(_('Avg time')) +
          term.move_x(5 * col_width) +
          term.white('{0:.4f}'.format(exec_time))
          )
    return True
dataset/ETHPy150Open Koed00/django-q/django_q/monitor.py/info/swapped operands of `/`