コード例 #1
0
def ss_input():
    #db2 = mdb.connect(user="******", host="localhost", passwd='hats', db="ssf_db", charset='utf8')
    bottom_games, alternatives = support.recommend_games(10,60.00)
    
    '''not really dry, but works for now'''    
    left_g = bottom_games[0] #left,center,right are the appids fed into the html template for the graphics call
    center_g = bottom_games[1]
    right_g = bottom_games[2]
    
    _cps, left_p, _dc, _osc = support.get_rec_price(left_g,alternatives)
    _cps, center_p, _dc, _osc = support.get_rec_price(center_g,alternatives)
    _cps, right_p, _dc, _osc = support.get_rec_price(right_g,alternatives)
    
    return render_template("ssinput.html",left_id = left_g, cent_id = center_g, 
                           right_id = right_g,left_price = left_p, right_price = left_p,
                           center_price = center_p,
                           option_list = OPTION_LIST) #currently the index  
コード例 #2
0
def ss_output():
    game_id =  int(request.args.get('option')) #get the game_id from the option selected by the user
    appid= game_id # merged two different functions, for the rest of it, use appid until I can make sure everything works exactly as intended
    db2 = mdb.connect(user="******", host="localhost", passwd=pw, db="ssf_db", charset='utf8')
    with db2:
        cur = db2.cursor(mdb.cursors.DictCursor)
        cur.execute("SELECT * FROM website_table WHERE appid = %d" % appid)

    ginfo = cur.fetchone() #there should only be one, but better safe
    gname = ginfo['game_name']
    
    adisc_num = ginfo['avg_discount']
    asavings_num = ginfo['avg_savings']
    if adisc_num == None:
        adisc_num = 0
    if asavings_num == None:
        asavings_num = 0
        
    adiscount = "%0.1f%%" % (adisc_num)
    asavings = "$%0.2f" % (asavings_num)
    sale_prob = ginfo['sale_prob_y']*100
    if sale_prob == 0:  
        sale_prob = 1 #correction so that a sale is never 0 percent
    elif sale_prob == 100:
        sale_prob = 90 #correction so that a sale is never going to be reported as 100%
    
    cur_price_str,cur_price,cur_disc, on_sale_currently = support.get_current_price(appid) #from steam, get the most current price
            
    
    percent = "%0.1f%%" % (sale_prob)
    if percent == '1.0%':
        percent = '< 1%' #change from reporting 1% to less than 1%
    

    recomendation_score = support.rec_val(asavings_num,sale_prob * 0.01)
    if recomendation_score < 0.5:
        buy_time = 'buy %s now, since it is not likely to go on sale soon.' % (gname)
    else:
        buy_time = 'wait for a sale.'
        
    bottom_games, alternatives = support.recommend_games(appid,float(cur_price.strip('$')))
    
    '''not really dry, but works for now'''    
    left_g = bottom_games[0] #left,center,right are the appids fed into the html template for the graphics call
    center_g = bottom_games[1]
    right_g = bottom_games[2]
    
    _cps, left_p, _dc, _osc = '','','',''#support.get_rec_price(left_g,alternatives) #fix later if needed
    _cps, center_p, _dc, _osc = '','','','' #support.get_rec_price(center_g,alternatives)
    _cps, right_p, _dc, _osc = '','','',''#support.get_rec_price(right_g,alternatives)
    
    return render_template("ssoutput3.html", 
                           appid = appid,option_list = OPTION_LIST,
                           name = gname, discount = adiscount, 
                           savings = asavings, percent = percent,
                           buy_time = buy_time, cur_discount = cur_disc,
                           cur_price = cur_price,
                           left_id = left_g, cent_id = center_g, 
                           right_id = right_g,
                           left_price = left_p, right_price = right_p,
                           center_price = center_p) #add back in "game info" later