Example #1
0
def product_result(home_lable, date, catogory_name, product_id, product_name):
    global products, cart_product_counts, order_product_counts, product_unique_visitor
    print '{8},{7},{0},{1},{2},{3},{4},{5},{6}'.format( catogory_name,'product',\
            idu.decode_product(product_id),products.get(product_id,0),\
            cart_product_counts.get(product_id,0),order_product_counts.get(product_id,0),\
            product_unique_visitor.get(product_id,0),date,home_lable)
    db.update_home_statics(home_lable,date,catogory_name,'product',\
            idu.decode_product(product_id),products.get(product_id,0),\
            cart_product_counts.get(product_id,0),order_product_counts.get(product_id,0),\
            product_unique_visitor.get(product_id,0))
Example #2
0
def product_result(home_lable,date,catogory_name,product_id,product_name):
    global products,cart_product_counts,order_product_counts,product_unique_visitor
    print '{8},{7},{0},{1},{2},{3},{4},{5},{6}'.format( catogory_name,'product',\
            idu.decode_product(product_id),products.get(product_id,0),\
            cart_product_counts.get(product_id,0),order_product_counts.get(product_id,0),\
            product_unique_visitor.get(product_id,0),date,home_lable)
    db.update_home_statics(home_lable,date,catogory_name,'product',\
            idu.decode_product(product_id),products.get(product_id,0),\
            cart_product_counts.get(product_id,0),order_product_counts.get(product_id,0),\
            product_unique_visitor.get(product_id,0))
Example #3
0
def showStatics(article_id,product_id):
    article_sum=articles['ids'][article_id] if article_id in articles['ids'].keys() else 0
    product_sum=products['ids'][product_id] if product_id in products['ids'].keys() else 0
    order_sum=orders['ids'][product_id] if product_id in orders['ids'].keys() else 0
    decrypt_article_id=id_util.decode_article(article_id).strip()
    decrypt_product_id=id_util.decode_product(product_id).strip()
    pattern='article {0:10}:{1:10} ,product {2:10}:{3:10} ,orders {4}'
    print pattern.format(decrypt_article_id,article_sum,decrypt_product_id,product_sum,order_sum)
Example #4
0
def product_record(date):
    global products
    for product_id in products.keys():
        pv = products.get(product_id, 0)
        product_id = idu.decode_product(product_id)
        if not db.update_product(product_id, pv, date):
            db.update_product(product_id, pv, date)
            print product_id, pv, date, 'retry'
        else:
            print product_id, pv, date, 'success'
Example #5
0
def product_record(date):
    global products
    for product_id in products.keys():
        pv=products.get(product_id,0)
        product_id=idu.decode_product(product_id)
        if not db.update_product(product_id,pv,date):
            db.update_product(product_id,pv,date)
            print product_id,pv,date,'retry'
        else:
            print product_id,pv,date,'success'
Example #6
0
def product_statics(datetime,limit):
    print datetime
    data=''
    product_df=da.getDataFrame('product',datetime)
    condition=pd.notnull(product_df['device_id'])
    result=da.rowGroupCount(product_df[condition],'values')
    order_product_counts=da.getOrderCounts(datetime)
    cart_product_counts=da.getCartCount(datetime)
    unique_visitor=da.getUniqueDevice(datetime,'product','values')
    product_ids=result.keys()
    data+=pr_format.format('date','product_id','product_pv','cart_count','order_count','unique_visitor')
    for product_id in product_ids:
        data+=pr_format.format(datetime,id_util.decode_product(product_id),result.get(product_id,0),\
                cart_product_counts.get(product_id,0),\
                order_product_counts.get(product_id,0),\
                unique_visitor.get(product_id,0))
    data+=all_pr_format.format('sum',len(result.keys()),sum(result),\
            sum(cart_product_counts),\
            sum(order_product_counts),\
            da.getActiveUser(datetime),\
            da.getAllUser(datetime),\
            len(product_df['device_id'].unique()))
    da.write2CsvFile(datetime,'product',data)
Example #7
0
def product_statics(datetime, limit):
    print datetime
    data = ''
    product_df = da.getDataFrame('product', datetime)
    condition = pd.notnull(product_df['device_id'])
    result = da.rowGroupCount(product_df[condition], 'values')
    order_product_counts = da.getOrderCounts(datetime)
    cart_product_counts = da.getCartCount(datetime)
    unique_visitor = da.getUniqueDevice(datetime, 'product', 'values')
    product_ids = result.keys()
    data += pr_format.format('date', 'product_id', 'product_pv', 'cart_count',
                             'order_count', 'unique_visitor')
    for product_id in product_ids:
        data+=pr_format.format(datetime,id_util.decode_product(product_id),result.get(product_id,0),\
                cart_product_counts.get(product_id,0),\
                order_product_counts.get(product_id,0),\
                unique_visitor.get(product_id,0))
    data+=all_pr_format.format('sum',len(result.keys()),sum(result),\
            sum(cart_product_counts),\
            sum(order_product_counts),\
            da.getActiveUser(datetime),\
            da.getAllUser(datetime),\
            len(product_df['device_id'].unique()))
    da.write2CsvFile(datetime, 'product', data)
Example #8
0
def product_result(product_id, product_name):
    global products, cart_product_counts, order_product_counts
    return 'product_id:{3},{0},{1},{2}\n'.format( products.get(product_id,0),\
            cart_product_counts.get(product_id,0),\
            order_product_counts.get(product_id,0),\
            id_util.decode_product(product_id))
Example #9
0
def product_result(product_id,product_name):
    global products,cart_product_counts,order_product_counts
    return 'product_id:{3},{0},{1},{2}\n'.format( products.get(product_id,0),\
            cart_product_counts.get(product_id,0),\
            order_product_counts.get(product_id,0),\
            id_util.decode_product(product_id))