Example #1
0
def get_filter_values(table, column):

    if table == 'groups':
        values = MongoDBConnection.get_groups_collection().distinct(column)
    elif table == 'students':
        values = MongoDBConnection.get_students_collection().distinct(column)
    elif table == 'test':
        values = MongoDBConnection.get_tests_collection().distinct(column)
    elif table == 'saved_state':
        values = MongoDBConnection.get_saved_state_collection().distinct(
            column)
    elif table == 'games':
        values = MongoDBConnection.get_games_collection().distinct(column)
    elif table == 'chapters':
        values = MongoDBConnection.get_chapters_collection().distinct(column)
    elif table == 'events':
        values = MongoDBConnection.get_events_collection().distinct(column)
    elif table == 'decisions':
        values = MongoDBConnection.get_decisions_collection().distinct(column)

    try:
        values = list(map(int, values))
        return [min(values), max(values)]
    except:
        return values
Example #2
0
def get_group_filter_values(group_ids: List[str], column: str) -> List[str]:
    db = MongoDBConnection.get_groups_collection()
    return db.find({
        'groupCode': {
            '$in': group_ids
        }
    }, {
        '_id': 0,
        column: 1
    }).distinct(column)
Example #3
0
def get_groups_pass_filter(query: dict) -> List[str]:
    db = MongoDBConnection.get_groups_collection()
    return db.find(query, {'groupCode': 1}).distinct('groupCode')
Example #4
0
def get_groups(ids: List[str]) -> pymongo.cursor.Cursor:
    return MongoDBConnection.get_groups_collection().find(
        {'groupCode': {
            '$in': ids
        }})
Example #5
0
def get_group(id):
    return MongoDBConnection.get_groups_collection().find_one(
        {'groupCode': id})
Example #6
0
def get_game_countries(game_code, version, students):
    db = MongoDBConnection.get_students_collection()
    groups = db.find({"studentCode": {"$in": students}}).distinct('groupCode')

    db = MongoDBConnection.get_groups_collection()
    return db.find({"groupCode": {"$in": groups}}).distinct('country')