Exemplo n.º 1
0
def update_userannostate_schema(cursor=None):
    userannostate_list, cursor, more = UserAnnoState.query().fetch_page(BATCH_SIZE, start_cursor=cursor)

    userannostate_update_list = []
    for userannostate in userannostate_list:
        if not userannostate.tagged:
            userannostate.tagged = False
            userannostate_update_list.append(userannostate)

    if len(userannostate_update_list):
        ndb.put_multi(userannostate_update_list)

    if more:
        update_userannostate_schema(cursor=cursor)
Exemplo n.º 2
0
    def query_by_my_mentions_for_dashboard(cls, limit, curs, user):
        query = cls.query()
        query = query.order(-cls.created)
        query = filter_anno_by_user(query, user, True)

        from model.userannostate import UserAnnoState
        userannostate_list = UserAnnoState.query().filter(ndb.AND(UserAnnoState.user == user.key, UserAnnoState.tagged == True)).fetch()
        anno_list = [ userannostate.anno.id() for userannostate in userannostate_list]
        if len(anno_list):
            query = query.filter(cls.anno_id.IN(anno_list))

            annos, next_curs, more = query.fetch_page(limit, start_cursor=curs)
            items = [entity.to_dashboard_response_message(user) for entity in annos]

            if more:
                return AnnoDashboardListMessage(anno_list=items, cursor=next_curs.urlsafe(), has_more=more)
            else:
                return AnnoDashboardListMessage(anno_list=items, has_more=more)
        else:
            return AnnoDashboardListMessage(anno_list=[])