Пример #1
0
def article_result(home_lable, date, catogory_name, article_id, article_name):
    global articles, article_unique_visitor
    print '{6},{5},{0},{1},{2},{3},{4}'.format(catogory_name,'article',\
            idu.decode_article(article_id),articles.get(article_id,0),\
            article_unique_visitor.get(article_id,0),date,home_lable)
    db.update_home_statics(home_lable,date,catogory_name,'article',\
            idu.decode_article(article_id),articles.get(article_id,0),0,0,\
            article_unique_visitor.get(article_id,0))
Пример #2
0
def article_result(home_lable,date,catogory_name,article_id,article_name):
    global articles,article_unique_visitor
    print '{6},{5},{0},{1},{2},{3},{4}'.format(catogory_name,'article',\
            idu.decode_article(article_id),articles.get(article_id,0),\
            article_unique_visitor.get(article_id,0),date,home_lable)
    db.update_home_statics(home_lable,date,catogory_name,'article',\
            idu.decode_article(article_id),articles.get(article_id,0),0,0,\
            article_unique_visitor.get(article_id,0))
Пример #3
0
def article_result(article_id,article_name):
    global articles
    product_ids=map(id_util.encode_product,api_util.getProductIdInArticle(article_id))
    result=map(lambda x :product_result(x,''),product_ids)
    return 'article_id:{2},{0}\n   {1}\n'.format(articles.get(article_id,0),\
            '\n '.join(result),\
            id_util.decode_article(article_id))
Пример #4
0
def article_result(article_id, article_name):
    global articles
    product_ids = map(id_util.encode_product,
                      api_util.getProductIdInArticle(article_id))
    result = map(lambda x: product_result(x, ''), product_ids)
    return 'article_id:{2},{0}\n   {1}\n'.format(articles.get(article_id,0),\
            '\n '.join(result),\
            id_util.decode_article(article_id))
Пример #5
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)
Пример #6
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)
Пример #7
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)