__init__.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:lagendacommun 作者: ecreall 项目源码 文件源码
def states_analyzer(node, source, validated):
    """Return for example
    {'states': {
      'editable': 250, 'published': 16264, 'archived': 269, 'active': 3}
    }
    """
    if 'metadata_filter' in validated:
        validated['metadata_filter'].pop('states', None)

    objects = source(**validated)
    index = find_catalog('dace')['object_states']
    intersection = index.family.IF.intersection
    object_ids = getattr(objects, 'ids', objects)
    if isinstance(object_ids, (list, types.GeneratorType)):
        object_ids = index.family.IF.Set(object_ids)

    result = [(state_id, len(intersection(object_ids, oids)))
              for state_id, oids in index._fwd_index.items()]
    result = dict([(k, v) for k, v in result if v != 0])
    return {'states': result}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号