def get_pillow_json(pillow_config):
    assert isinstance(pillow_config, PillowConfig)
    from pillowtop.listener import AliasedElasticPillow

    pillow_class = pillow_config.get_class()
    pillow = (pillow_class(online=False) if issubclass(pillow_class, AliasedElasticPillow)
              else pillow_config.get_instance())

    checkpoint = pillow.get_checkpoint()
    timestamp = checkpoint.timestamp
    if timestamp:
        time_since_last = datetime.utcnow() - timestamp
        hours_since_last = time_since_last.total_seconds() // 3600

        try:
            # remove microsecond portion
            time_since_last = str(time_since_last)
            time_since_last = time_since_last[0:time_since_last.index('.')]
        except ValueError:
            pass
    else:
        time_since_last = ''
        hours_since_last = None
    try:
        db_seq = pillow.get_change_feed().get_latest_change_id()
    except ValueError:
        db_seq = None
    return {
        'name': pillow_config.name,
        'seq': force_seq_int(checkpoint.wrapped_sequence),
        'old_seq': force_seq_int(checkpoint.old_sequence) or 0,
        'db_seq': force_seq_int(db_seq),
        'time_since_last': time_since_last,
        'hours_since_last': hours_since_last
    }
dataset/ETHPy150Open dimagi/commcare-hq/corehq/ex-submodules/pillowtop/utils.py/get_pillow_json/original