Beispiel #1
0
 def getLogin_player(self, query_key, time_format, querys_addition=None):
     """ log_info登陆记录 """
     D_U = 'd.u'
     e_name = FilterPlayer.get_pids()
     e_list = FilterPlayer.get_uids()
     mongo_log = MongoFive(self.db, self.collection, self.host)
     querys = {
         query_key: {
             EXT.MONGO_GTE: self.start_time,
             EXT.MONGO_LTE: self.end_time
         }
     }
     if querys_addition:
         querys.update(querys_addition)
     # 获取登录角色
     uids = {}
     ret = {}
     players = mongo_log.filter(querys)
     for p in players:
         day = time_to_hour(p[query_key], time_format)
         if day in ret:
             ret[day] += 1
         else:
             ret[day] = 1
     return ret
Beispiel #2
0
 def getLogin(self, query_key, time_format, querys_addition=None):
     """ log_info登陆记录 """
     D_U = 'd.u'
     e_name = FilterPlayer.get_pids()
     e_list = FilterPlayer.get_uids()
     mongo_log = MongoFive(self.db, self.collection, self.host)
     querys = {
         query_key: {
             EXT.MONGO_GTE: self.start_time,
             EXT.MONGO_LTE: self.end_time
         }
     }
     if querys_addition:
         querys.update(querys_addition)
     # 获取登录角色
     uids = {}
     ret = {}
     players = mongo_log.filter(querys)
     for p in players:
         if EXT.KEY_D not in p:
             continue
         if EXT.KEY_U not in p[EXT.KEY_D]:
             continue
         day = time_to_hour(p[query_key], time_format)
         if day in uids and p[EXT.KEY_D][EXT.KEY_U] in uids[day]:
             continue
         if day in ret:
             ret[day] += 1
         else:
             ret[day] = 1
         if day in uids:
             uids[day].append(p[EXT.KEY_D][EXT.KEY_U])
         else:
             uids[day] = [p[EXT.KEY_D][EXT.KEY_U]]
     return ret
Beispiel #3
0
    def getNewPlayer(self,
                     query_key,
                     time_list,
                     time_range=EXT.NUM_UNIX_A_DAY,
                     querys_addition=None):
        """ 获取新充值人数 """
        ret = {}
        mongo = MongoFive(self.db, self.collection, self.host)
        for item in time_list:
            paid_querys = {
                query_key: {
                    EXT.MONGO_GTE: item,
                    EXT.MONGO_LT: item + time_range - 1
                }
            }
            if querys_addition:
                paid_querys.update(querys_addition)
            paid_ret = mongo.distince_filter(key=EXT.KEY_PID,
                                             querys=paid_querys)

            if not paid_ret:
                ret[item] = 0
                continue
            for p in paid_ret:
                paid_before = {query_key: {EXT.MONGO_LT: item}, EXT.KEY_PID: p}
                if querys_addition:
                    paid_before.update(querys_addition)
                paid_before_ret = mongo.first(dic=paid_before)
                if not paid_before_ret:
                    if item in ret:
                        ret[item] += 1
                    else:
                        ret[item] = 1
        return ret
Beispiel #4
0
    def getRetByQuerys(self, query_key, querys_addition=None):
        """ 条件查询 """
        mongo = MongoFive(self.db, self.collection, self.host)
        querys = {
            query_key: {
                EXT.MONGO_GTE: self.start_time,
                EXT.MONGO_LT: self.end_time
            }
        }

        if querys_addition:
            querys.update(querys_addition)
        return mongo.filter(dic=querys, sort=query_key)
Beispiel #5
0
 def count(self, time_list, query_key, **kw):
     ret = {}
     mongo = MongoFive(self.db, self.collection, self.host)
     for item in time_list:
         querys = {
             query_key: {
                 EXT.MONGO_GTE: item,
                 EXT.MONGO_LT: item + EXT.NUM_UNIX_A_DAY - 1
             }
         }
         if kw:
             querys.update(kw)
         ret[item] = mongo.count(dic=querys)
     return ret
Beispiel #6
0
 def getPlayer(self, query_key, time_list, count_key=EXT.KEY_PID, q=None):
     """ 获取充值角色数 """
     ret = {}
     mongo = MongoFive(self.db, self.collection, self.host)
     for item in time_list:
         paid_querys = {
             query_key: {
                 EXT.MONGO_GTE: item,
                 EXT.MONGO_LT: item + EXT.NUM_UNIX_A_DAY - 1
             }
         }
         if q:
             paid_querys.update(q)
         paid_ret = mongo.distince_filter(key=EXT.KEY_PID,
                                          querys=paid_querys)
         ret[item] = len(paid_ret)
     return ret
Beispiel #7
0
 def __init__(self, start_time, end_time):
     self.start_time = start_time
     self.end_time = end_time
     self.mongo = MongoFive(g.GAME_LOG, EXT.LOG_INFO, g.mongo_host)
Beispiel #8
0
 def __init__(self, start_time, end_time, database, searchCondition):
     super(OnlineCount, self).__init__()
     self.start_time = time_to_hour(start_time)
     self.end_time = time_to_hour(end_time)
     self.mongo = MongoFive(database[0], database[1], database[2])
     self.searchCondition = searchCondition