Exemplo n.º 1
0
    def list_sets(self, limit=10, skip=0, **params):
        """
        Join the user's set_ids with set information.
        Return empty list when there's no matching documents.
        """

        return Set.list_by_entity_ids(self['set_ids'])
Exemplo n.º 2
0
    def list_sets(self, db_conn, limit=10, skip=0, **params):
        """
        Join the user's set_ids with set information.
        Return empty list when there's no matching documents.
        """

        return Set.list_by_entity_ids(db_conn, self['set_ids'])
Exemplo n.º 3
0
def get_my_recently_created_sets(current_user, db_conn):
    """
    Get the user's most recently created sets.
    """

    proposals = get_my_recent_proposals(current_user, db_conn)
    unit_ids = get_proposal_entities(proposals, 'set')
    sets = Set.list_by_entity_ids(db_conn, unit_ids)
    return sets
Exemplo n.º 4
0
def list_user_sets_entity(user_id, params, db_conn):
    """
    Join the user's set_ids with set information.
    Return empty list when there's no matching documents.
    """

    # TODO-2 each set -- needs review?
    # TODO-2 order by last reviewed time
    uset = get_user_sets(user_id, db_conn)
    # TODO-3 limit = params.get('limit') or 10
    # TODO-3 skip = params.get('skip') or 0
    return Set.list_by_entity_ids(db_conn, uset['set_ids'])
Exemplo n.º 5
0
def test_list_by_entity_ids(db_conn, sets_table):
    """
    Expect to list sets by given entity IDs.
    """

    sets_table.insert(
        [
            {
                "entity_id": "A1",
                "name": "A",
                "body": "Apple",
                "created": r.now(),
                "modified": r.now(),
                "status": "accepted",
            },
            {
                "entity_id": "B2",
                "name": "B",
                "body": "Banana",
                "created": r.now(),
                "modified": r.now(),
                "status": "accepted",
            },
            {
                "entity_id": "C3",
                "name": "C",
                "body": "Coconut",
                "created": r.now(),
                "modified": r.now(),
                "status": "accepted",
            },
            {
                "entity_id": "D4",
                "name": "D",
                "body": "Date",
                "created": r.now(),
                "modified": r.now(),
                "status": "accepted",
            },
        ]
    ).run(db_conn)
    sets = Set.list_by_entity_ids(db_conn, ["A1", "C3"])
    assert sets[0]["body"] in ("Apple", "Coconut")
    assert sets[0]["body"] in ("Apple", "Coconut")
Exemplo n.º 6
0
def test_list_by_entity_ids(db_conn, sets_table):
    """
    Expect to list sets by given entity IDs.
    """

    sets_table.insert([{
        'entity_id': 'A1',
        'name': 'A',
        'body': 'Apple',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }, {
        'entity_id': 'B2',
        'name': 'B',
        'body': 'Banana',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }, {
        'entity_id': 'C3',
        'name': 'C',
        'body': 'Coconut',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }, {
        'entity_id': 'D4',
        'name': 'D',
        'body': 'Date',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }]).run(db_conn)
    sets = Set.list_by_entity_ids(['A1', 'C3'])
    assert sets[0]['body'] in ('Apple', 'Coconut')
    assert sets[0]['body'] in ('Apple', 'Coconut')
Exemplo n.º 7
0
def test_list_by_entity_ids(db_conn, sets_table):
    """
    Expect to list sets by given entity IDs.
    """

    sets_table.insert([{
        'entity_id': 'A1',
        'name': 'A',
        'body': 'Apple',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }, {
        'entity_id': 'B2',
        'name': 'B',
        'body': 'Banana',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }, {
        'entity_id': 'C3',
        'name': 'C',
        'body': 'Coconut',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }, {
        'entity_id': 'D4',
        'name': 'D',
        'body': 'Date',
        'created': r.now(),
        'modified': r.now(),
        'status': 'accepted',
    }]).run(db_conn)
    sets = Set.list_by_entity_ids(db_conn, ['A1', 'C3'])
    assert sets[0]['body'] in ('Apple', 'Coconut')
    assert sets[0]['body'] in ('Apple', 'Coconut')