Beispiel #1
0
def get_user_profile(conn_func):
    conn = conn_func()
    sql = "select id, grade_id, exam from user_profile"
    A = pd.read_sql_query(sql, conn)
    A.columns = ["uid", "grade_id", "exam_type"]
    res = {}
    for _, row in A.iterrows():
        uid, grade_id, exam_type = row
        exam_kind = EXAM_KIND_MAP.get(grade_id, {}).get(exam_type, EXAM_KIND_DEFAULT)
        res[uid] = exam_kind
    return res
Beispiel #2
0
def get_user_profile(conn_func):
    conn = conn_func()
    sql = 'select id, grade_id, exam from user_profile'
    A = pd.read_sql_query(sql, conn)
    A.columns = ['uid', 'grade_id', 'exam_type']
    res = {}
    for _, row in A.iterrows():
        uid, grade_id, exam_type = row
        exam_kind = EXAM_KIND_MAP.get(grade_id,
                                      {}).get(exam_type, EXAM_KIND_DEFAULT)
        res[uid] = exam_kind
    return res
Beispiel #3
0
def get_origin(conn_func):
    conn = conn_func()
    cursor = conn.cursor()
    cursor.execute('select target_kind, target_id, '
                   'grade_id, exam_type from origin')
    origin = {}
    for qtype, qid, grade_id, etype in cursor.fetchall():
        ekind = EXAM_KIND_MAP.get(grade_id, EXAM_KIND_DEFAULT)
        if qtype not in origin:
            origin[qtype] = {}
        # 每道题目可能有多个 origin 来源
        origin[qtype].setdefault(qid, []).append((grade_id, etype, ekind))
    cursor.close()
    conn.close()
    return origin
Beispiel #4
0
def get_origin(conn_func):
    conn = conn_func()
    cursor = conn.cursor()
    cursor.execute('select target_kind, target_id, '
                   'grade_id, exam_type from origin')
    origin = {}
    for qtype, qid, grade_id, etype in cursor.fetchall():
        ekind = EXAM_KIND_MAP.get(grade_id, {}).get(etype, EXAM_KIND_DEFAULT)
        if qtype not in origin:
            origin[qtype] = {}
        # 每道题目可能有多个 origin 来源
        origin[qtype].setdefault(qid, []).append((grade_id, etype, ekind))
    cursor.close()
    conn.close()
    return origin