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)
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)
def community_static(datetime): global like_df,follow_df,view_df,reply_df likes=da.rowGroupCount(like_df,'values') follows=da.rowGroupCount(follow_df,'values') views=da.rowGroupCount(view_df,'values') replies=da.rowGroupCount(reply_df,'values') result='\n' result=result+pr_format.format('topic_id','view_count','like','follow','reply') for topic_id in views.keys()[:50]: result=result+pr_format.format(id_util.decode_topic(topic_id),views.get(topic_id,0),likes.get(topic_id,0),\ follows.get(topic_id,0),replies.get(topic_id,0)) result+='sum\n' result+=pr_format.format(len(views.keys()),sum(views),sum(likes),sum(follows),sum(replies)) return result
def community_summarize(datetime): global list_df,create_df,privateMsg_df result='' result+='private_message,'+str(len(privateMsg_df))+'\n\n' lists=da.rowGroupCount(list_df,'values') creates=da.rowGroupCount(create_df,'values') users=da.getUniqueDevice(datetime,'topic_list','values') result=result+sum_pr_format.format('node_id','node_pv','topic_create','user') for node_id in lists.keys(): result=result+sum_pr_format.format(id_util.decode_node(node_id),lists[node_id],\ creates.get(node_id,0),users.get(node_id,0)) result=result+'sum\n' result=result+sum_pr_format.format(len(lists.keys()),sum(lists),sum(creates),sum(users)) return result
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')
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')
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)
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)
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)
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)
def product_list_record(date): list_df = da.getDataFrame('product_list', str(date).replace('-', '')) tags = da.rowGroupCount(list_df, 'values') for tag in tags.keys()[:10]: print tag, tags.get(tag, 0)
def product_list_record(date): list_df=da.getDataFrame('product_list',str(date).replace('-','')) tags=da.rowGroupCount(list_df,'values') for tag in tags.keys()[:10]: print tag,tags.get(tag,0)