Exemplo n.º 1
0
def getTrainData(userid,start,end):
    return dbconn.query("""
        select * from user_train_data where id in(
            select max(id) from user_train_data where userid=$userid and userCyclingTimeStamp between $start and $end
            group by date(userCyclingTimeStamp)
        )
        """,vars=dict(userid=userid,start=start,end=end))
Exemplo n.º 2
0
def getTrainData(userid, start, end):
    return dbconn.query("""
        select * from user_train_data where id in(
            select max(id) from user_train_data where userid=$userid and userCyclingTimeStamp between $start and $end
            group by date(userCyclingTimeStamp)
        )
        """,
                        vars=dict(userid=userid, start=start, end=end))
Exemplo n.º 3
0
def getLastTimeStamp(userid):
    r = web.listget(
        dbconn.query(
            "select max(timeStamp) as timeStamp from user_data where userid=$userid",
            vars=dict(userid=userid)), 0, None)
    if r:
        return date_to_timestamp(r.timeStamp)
    return None
Exemplo n.º 4
0
def getUserByID(userid):
    res = dbconn.query("""
                            select * from user_info ui
                                 where ui.userid = $userid
                       """,
                       vars=dict(userid=userid))
    u = web.listget(res, 0, None)
    return u
Exemplo n.º 5
0
def updatenafens(brand=None,market=None):
    if not market:
        return
    res = dbconn.query("select * from naifen where processed is null and market = $market and brand = $brand",vars=dict(market=market,brand=brand))
    dp = None
    if market == "tmall":
        dp = Tmall()
    elif market == "amazon":
        dp = Amazon()
    elif market == "jd":
        dp = Jd()

    for r in res:
        dp.initNf(r.itemid)
Exemplo n.º 6
0
def get_rank(userid):
    rs = dbconn.query("""
        select userid,max(userCyclingStamina) as max_stamina from user_train_data
        where userCyclingTimeStamp > $sunday 
        group by userid
        order by max(userCyclingStamina) desc
    """,vars=dict(sunday=get_last_Sunday()))
    rank = 1
    for r in rs:
        print type(r.userid)
        print type(userid)
        if r.userid == userid:
            print "==========="
            return {"rank":rank,"userCyclingStamina":r.max_stamina}
        rank += 1
Exemplo n.º 7
0
def get_rank(userid):
    rs = dbconn.query("""
        select userid,max(userCyclingStamina) as max_stamina from user_train_data
        where userCyclingTimeStamp > $sunday 
        group by userid
        order by max(userCyclingStamina) desc
    """,
                      vars=dict(sunday=get_last_Sunday()))
    rank = 1
    for r in rs:
        print type(r.userid)
        print type(userid)
        if r.userid == userid:
            print "==========="
            return {"rank": rank, "userCyclingStamina": r.max_stamina}
        rank += 1
Exemplo n.º 8
0
def get_ranks(start,end):
    rs = dbconn.query("""
        select username,max(userCyclingStamina) as max_stamina from user_train_data ut
            join user_info ui
            on ui.userid = ut.userid
        where userCyclingTimeStamp > $sunday
        group by ut.userid
        order by max(userCyclingStamina) desc
        limit $start,$n
    """,
        vars = dict(start=(start-1),n=(end-start+1),sunday=get_last_Sunday())
    )
    l = list()
    for r in rs:
        l.append({"username":r.username,"rank":start,"stamina":r.max_stamina})
        start += 1
    return l 
Exemplo n.º 9
0
def get_ranks(start, end):
    rs = dbconn.query("""
        select username,max(userCyclingStamina) as max_stamina from user_train_data ut
            join user_info ui
            on ui.userid = ut.userid
        where userCyclingTimeStamp > $sunday
        group by ut.userid
        order by max(userCyclingStamina) desc
        limit $start,$n
    """,
                      vars=dict(start=(start - 1),
                                n=(end - start + 1),
                                sunday=get_last_Sunday()))
    l = list()
    for r in rs:
        l.append({
            "username": r.username,
            "rank": start,
            "stamina": r.max_stamina
        })
        start += 1
    return l
Exemplo n.º 10
0
def hasUserName(userName):
    return web.listget(
        dbconn.query("select * from user_info where userName=$userName",
                     vars=dict(userName=userName)), 0, None)
Exemplo n.º 11
0
def insertpre(itemid,market):
    dbconn.query("insert into prenaifen (name,duration,weight,spec,brand,series,sellto,age,duan,pack,place,price,img) select name,duration,weight,spec,brand,series,sellto,age,duan,pack,place,price,img from naifen where itemid = $itemid and market=$market",vars=dict(itemid=itemid,market=market))
    ""
    return web.listget(dbconn.query("SELECT last_insert_id() as newid"),0,None).newid
Exemplo n.º 12
0
def get_session(session_id):
    res = dbconn.query("select * from sessions where session_id = $session_id",vars=dict(session_id=session_id))
    return web.listget(res,0,None)
Exemplo n.º 13
0
def getLastTimeStamp(userid):
    r = web.listget( dbconn.query("select max(timeStamp) as timeStamp from user_data where userid=$userid",vars=dict(userid=userid)), 0, None)
    if r:
        return date_to_timestamp(r.timeStamp)
    return None
Exemplo n.º 14
0
def getData(userid,start,end):
    return dbconn.query("select * from user_data where userid=$userid and timeStamp between $start and $end",vars=dict(userid=userid,start=start,end=end))
Exemplo n.º 15
0
def get_session(session_id):
    res = dbconn.query("select * from sessions where session_id = $session_id",
                       vars=dict(session_id=session_id))
    return web.listget(res, 0, None)
Exemplo n.º 16
0
def getfamsp(pid):
    return dbconn.query("select * from formalitem where pid = $pid and picked=0 order by generalscore desc",vars=dict(pid=pid))
Exemplo n.º 17
0
def getsp(spid):
    return web.listget(dbconn.query("select * from formalitem where id=$spid",vars=dict(spid=spid)),0,None)
Exemplo n.º 18
0
def getData(userid, start, end):
    return dbconn.query(
        "select * from user_data where userid=$userid and timeStamp between $start and $end",
        vars=dict(userid=userid, start=start, end=end))
Exemplo n.º 19
0
def getUserByEmail(email):
    return web.listget(
        dbconn.query("select * from user_info where email=$email",
                     vars=dict(email=email)), 0, None)