def __init__(self, cf): conf = dict() conf['host'] = cf.get('online_db', 'host') conf['user'] = cf.get('online_db', 'user') conf['passwd'] = cf.get('online_db', 'passwd') conf['name'] = cf.get('online_db', 'name') conf['port'] = cf.getint('online_db', 'port') conf['charset'] = cf.get('online_db', 'charset') self.shop_dao = MysqlDao(conf) conf['host'] = cf.get('online_db', 'sea_host') conf['user'] = cf.get('online_db', 'sea_user') conf['passwd'] = cf.get('online_db', 'sea_passwd') conf['name'] = cf.get('online_db', 'sea_name') conf['port'] = cf.getint('online_db', 'sea_port') conf['charset'] = cf.get('online_db', 'sea_charset') self.sea_dao = MysqlDao(conf) self.page_size = cf.getint('online_db', 'page_size')
def __init__(self, cf): self.act_id = cf.getint('coupon', 'act_id') self.page_size = cf.getint('online_db', 'page_size') self.date_period = [cf.getint('coupon', 'start_date'), cf.getint('coupon', 'end_date')] conf = dict() conf['host'] = cf.get('online_db', 'host') conf['user'] = cf.get('online_db', 'user') conf['passwd'] = cf.get('online_db', 'passwd') conf['name'] = cf.get('online_db', 'name') conf['port'] = cf.getint('online_db', 'port') conf['charset'] = cf.get('online_db', 'charset') self.dao = MysqlDao(conf) self.hits_conf = dict() self.hits_conf[30] = cf.getfloat('coupon', 'hits_30') self.hits_conf[50] = cf.getfloat('coupon', 'hits_50') self.hits_conf[100] = cf.getfloat('coupon', 'hits_100') self.hits_conf[300] = cf.getfloat('coupon', 'hits_300') self.hits_conf[500] = cf.getfloat('coupon', 'hits_500')
def stat_result(self): conf = dict() conf['host'] = self.cf.get('online_db', 'host') conf['user'] = self.cf.get('online_db', 'user') conf['passwd'] = self.cf.get('online_db', 'passwd') conf['name'] = self.cf.get('online_db', 'name') conf['charset'] = self.cf.get('online_db', 'charset') conf['port'] = self.cf.getint('online_db', 'port') dao = MysqlDao(conf) unique_key = ['user_id', 'act_id'] for user_id, hits in self.user_hits.items(): db_dict = dict() db_dict['user_id'] = user_id db_dict['act_id'] = self.act_id db_dict['hits'] = hits db_dict['is_deleted'] = 'N' dao.insert_or_update_template('db_hd_share_hits', db_dict, unique_key) print '统计nginx log得到%d位用户的点击量' % len(self.user_hits)