本文整理汇总了Python中data.DataApi.DataApi.getRecentActivities方法的典型用法代码示例。如果您正苦于以下问题:Python DataApi.getRecentActivities方法的具体用法?Python DataApi.getRecentActivities怎么用?Python DataApi.getRecentActivities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data.DataApi.DataApi
的用法示例。
在下文中一共展示了DataApi.getRecentActivities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getRecentVisionActivity
# 需要导入模块: from data.DataApi import DataApi [as 别名]
# 或者: from data.DataApi.DataApi import getRecentActivities [as 别名]
def getRecentVisionActivity(user):
"""Get list of visions we want to display from the recent activities"""
# Get list of potential visions
activities = DataApi.getRecentActivities()
commentIds = set([a.objectId for a in activities if a.action == Activity.Action.COMMENT_ON_VISION])
commentModels = DataApi.getVisionCommentsById(commentIds)
idToComment = dict([(c.id, c) for c in commentModels])
visionIds = set([a.objectId for a in activities if a.action == Activity.Action.ADD_VISION])
for c in commentModels:
visionIds.add(c.visionId)
visionModels = DataApi.getVisionsById(visionIds, allowRemovedVisions=True)
idToVision = dict([(v.id, v) for v in visionModels])
# Now create ordered list without visions that have a duplicate
# root vision, and without private visions
rootIds = set()
orderedVisions = []
for a in activities:
vision = None
if a.action == Activity.Action.ADD_VISION:
if a.objectId in idToVision:
vision = idToVision[a.objectId]
elif a.action == Activity.Action.COMMENT_ON_VISION:
if a.objectId in idToComment:
comment = idToComment[a.objectId]
if comment.visionId in idToVision:
vision = idToVision[comment.visionId]
if (
vision
and vision.removed == False
and vision.privacy == VisionPrivacy.PUBLIC
and vision.rootId not in rootIds
):
orderedVisions.append(vision)
rootIds.add(vision.rootId)
return VisionList(orderedVisions)