示例#1
0
def init(datetime):
    global articles,products,order_product_counts,cart_product_counts,tags
    product_df=da.getDataFrame('product',datetime)
    article_df=da.getDataFrame('article',datetime)
    tags_df=da.getDataFrame('product_list',datetime)
    products=da.rowGroupCount(product_df[pd.notnull(product_df['device_id'])],'values')
    articles=da.rowGroupCount(article_df[pd.notnull(article_df['device_id'])],'values')
    tags=da.rowGroupCount(tags_df[pd.notnull(tags_df['device_id'])],'values')
    order_product_counts=da.getOrderCounts(datetime)
    cart_product_counts=da.getCartCount(datetime)
示例#2
0
def init(datetime):
    global articles, products, order_product_counts, cart_product_counts, tags
    product_df = da.getDataFrame('product', datetime)
    article_df = da.getDataFrame('article', datetime)
    tags_df = da.getDataFrame('product_list', datetime)
    products = da.rowGroupCount(
        product_df[pd.notnull(product_df['device_id'])], 'values')
    articles = da.rowGroupCount(
        article_df[pd.notnull(article_df['device_id'])], 'values')
    tags = da.rowGroupCount(tags_df[pd.notnull(tags_df['device_id'])],
                            'values')
    order_product_counts = da.getOrderCounts(datetime)
    cart_product_counts = da.getCartCount(datetime)
示例#3
0
def init(datetime):
    global articles,products,order_product_counts,cart_product_counts,tags,\
            product_unique_visitor,article_unique_visitor,tag_unique_visitor
    product_df = da.getDataFrame('product', datetime)
    article_df = da.getDataFrame('article', datetime)
    tags_df = da.getDataFrame('product_list', datetime)
    products = da.rowGroupCount(product_df, 'values')
    articles = da.rowGroupCount(article_df, 'values')
    tags = da.rowGroupCount(tags_df, 'values')
    order_product_counts = da.getOrderCounts(datetime)
    cart_product_counts = da.getCartCount(datetime)
    product_unique_visitor = da.getDfUniqueDevice(product_df, 'values')
    article_unique_visitor = da.getDfUniqueDevice(article_df, 'values')
    tag_unique_visitor = da.getDfUniqueDevice(tags_df, 'values')
示例#4
0
def init(datetime):
    global articles,products,order_product_counts,cart_product_counts,tags,\
            product_unique_visitor,article_unique_visitor,tag_unique_visitor
    product_df=da.getDataFrame('product',datetime)
    article_df=da.getDataFrame('article',datetime)
    tags_df=da.getDataFrame('product_list',datetime)
    products=da.rowGroupCount(product_df,'values')
    articles=da.rowGroupCount(article_df,'values')
    tags=da.rowGroupCount(tags_df,'values')
    order_product_counts=da.getOrderCounts(datetime)
    cart_product_counts=da.getCartCount(datetime)
    product_unique_visitor=da.getDfUniqueDevice(product_df,'values')
    article_unique_visitor=da.getDfUniqueDevice(article_df,'values')
    tag_unique_visitor=da.getDfUniqueDevice(tags_df,'values')
示例#5
0
def save_data(datetime,limit):
      product_view_counts=da.rowGroupCount(da.getDataFrame('product',datetime),'values')
      order_product_counts=da.getOrderCounts(datetime)
      cart_product_counts=da.getCartCount(datetime)
      result=da.rowGroupCount(da.getDataFrame('article',datetime),'values')
      article_ids=result.keys()[:limit]
      for article_id in article_ids:
          product_ids=api_util.getProductIdInArticle(article_id)
          if product_ids:
              for product_id in product_ids:
                  db.save_article_data(datetime,id_util.decode_article(article_id),result[article_id],product_id,\
                          da.getProductCounts(product_view_counts,id_util.encode_product(product_id)),\
                          da.getProductCounts(cart_product_counts,id_util.encode_product(product_id)),\
                          da.getProductCounts(order_product_counts,id_util.encode_product(product_id)))

          else:
              db.save_article_data(datetime,id_util.decode_article(article_id),result[article_id],0,0,0,0)
示例#6
0
def article_statics(datetime,limit):
    print datetime
    product_view_counts=da.rowGroupCount(da.getDataFrame('product',datetime),'values')
    order_product_counts=da.getOrderCounts(datetime)
    cart_product_counts=da.getCartCount(datetime)
    result=da.rowGroupCount(da.getDataFrame('article',datetime),'values')
    article_ids=result[:limit].keys()
    article_unique_device_counts=da.getUniqueDevice(datetime,'article','values')
    for article_id in article_ids:
        product_ids=api_util.getProductIdInArticle(article_id)
        unique_device_num=article_unique_device_counts.get(article_id,0)
        if product_ids:
            for product_id in product_ids:
                print show_format.format(id_util.decode_article(article_id),result[article_id],product_id,\
                        da.getProductCounts(product_view_counts,id_util.encode_product(product_id)),\
                        da.getProductCounts(cart_product_counts,id_util.encode_product(product_id)),\
                        da.getProductCounts(order_product_counts,id_util.encode_product(product_id)),\
                        unique_device_num)
        else:
            print show_format.format(id_util.decode_article(article_id),result[article_id],0,0,0,0,unique_device_num)
示例#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)
示例#8
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)