def set_data(self): last_info = DataWeichenUserStatsSource().get_info_someday( get_date_by_date(self.query_date)) compute = DataWeichenUserStatsCompute(self.query_date) field = { 'pay_user': compute.pay_user(), 'keep_user': compute.keep_user(), 'lose_user': compute.lose_user(), 'try_user': compute.try_user(), 'create_date': self.query_date, 'new_pay_user': 0, 'new_keep_user': 0, 'new_lose_user': 0, 'new_try_user': 0 } if last_info is not None: diff_user = field['pay_user'] - last_info['pay_user'] field['new_pay_user'] = diff_user if diff_user > 1 else 0 diff_user = field['keep_user'] - last_info['keep_user'] field['new_keep_user'] = diff_user if diff_user > 1 else 0 diff_user = field['lose_user'] - last_info['lose_user'] field['new_lose_user'] = diff_user if diff_user > 1 else 0 diff_user = field['try_user'] - last_info['try_user'] field['new_try_user'] = diff_user if diff_user > 1 else 0 self._data.append(field)
def last_user(self): count = 0 res = DataWeichenVersionStatsSource().get_info_someday( get_date_by_date(self.query_date), self.weichen_version, self.group_id) if res is not None: count = res['total_user'] return count
def _compute_field(self,field,type,module_name,weichen_version): field['type'] = type field['total_user'] = DataWeichenModuleStatsCompute(type, module_name, weichen_version).total_user() last_info = DataWeichenModuleStatsSource().get_module_info_someday(get_date_by_date(self.query_date), module_name, weichen_version, type) #上一天的数据 last_total_user = 0 if last_info is not None: last_total_user = last_info['total_user'] field['new_user'] = (field['total_user'] - last_total_user) if (field['total_user'] - last_total_user)>0 else 0 #今天减去昨天的用户数为新增用户 如果值为负则算为0 return field
def weichen_lose_user(self): return DataMiddleUserSource().count_weichen_lose_user(get_date_by_date(self.query_date,-15))