|
@@ -13,7 +13,7 @@ import logging
|
|
|
|
|
|
class MchDataCenter(object):
|
|
|
pos_map = {
|
|
|
- 'commit': 0, 'notify': 1
|
|
|
+ 'commit': 0, 'success': 1, 'fail': 2
|
|
|
}
|
|
|
|
|
|
def __init__(self):
|
|
@@ -42,11 +42,13 @@ class MchDataCenter(object):
|
|
|
hfive = h5py.File(self._file_name, 'w')
|
|
|
|
|
|
self.read_redis(hfive, r, 'nc_user_monitor_commit', 'commit')
|
|
|
- self.read_redis(hfive, r, 'nc_user_monitor_success', 'notify')
|
|
|
+ self.read_redis(hfive, r, 'nc_user_monitor_success', 'success')
|
|
|
+ self.read_redis(hfive, r, 'nc_user_monitor_fail', 'fail')
|
|
|
hfive.close()
|
|
|
|
|
|
self.del_redis(r, 'nc_user_monitor_commit')
|
|
|
self.del_redis(r, 'nc_user_monitor_success')
|
|
|
+ self.del_redis(r, 'nc_user_monitor_fail')
|
|
|
except Exception as ex:
|
|
|
print(ex)
|
|
|
finally:
|
|
@@ -94,7 +96,8 @@ class MchDataCenter(object):
|
|
|
today = self.day_stamp(time)
|
|
|
path = f'/{today}/{mchid}/{quality}/{card_type}/{amount}'
|
|
|
if path not in hfive:
|
|
|
- hfive[path] = np.zeros((2, 86400))
|
|
|
+ dim = len(self.pos_map)
|
|
|
+ hfive[path] = np.zeros((dim, 86400))
|
|
|
|
|
|
diff = time - today
|
|
|
if diff < 0:
|
|
@@ -190,7 +193,8 @@ class MchDataCenter(object):
|
|
|
fig = Figure(figsize=(16, 8))
|
|
|
ax = fig.subplots()
|
|
|
|
|
|
- predata = np.zeros((2, 86400))
|
|
|
+ dim = len(self.pos_map)
|
|
|
+ predata = np.zeros((dim, 86400))
|
|
|
x = np.arange(0, 86400, interval)
|
|
|
|
|
|
sub_count = 0
|
|
@@ -235,7 +239,8 @@ class MchDataCenter(object):
|
|
|
|
|
|
def _read_dict_data(self, hfive, mchPaths):
|
|
|
for mchid, paths in mchPaths.items():
|
|
|
- predata = np.zeros((2, 86400))
|
|
|
+ dim = len(self.pos_map)
|
|
|
+ predata = np.zeros((dim, 86400))
|
|
|
for path in paths:
|
|
|
predata += hfive[path]
|
|
|
yield mchid, predata
|
|
@@ -299,10 +304,10 @@ class MchDataCenter(object):
|
|
|
return filer_text, paths
|
|
|
|
|
|
def _draw_plot(self, ax, x, day_stamp, start_pos, end_pos, data, interval=300, path=''):
|
|
|
- # 'commit-succ': 0, 'commit-fail': 1, 'notify-succ': 2, 'notify-fail': 3, 'user_succ': 4
|
|
|
+ # 'commit-succ': 0, 'notify-succ': 1, 'notify-fail': 2
|
|
|
logging.getLogger('app').debug("path=%s", path)
|
|
|
|
|
|
- all = data[0]
|
|
|
+ all = data[1] + data[2]
|
|
|
all = all.reshape((-1, interval))
|
|
|
all = np.sum(all, axis=1)
|
|
|
|
|
@@ -389,13 +394,14 @@ class MchDataCenter(object):
|
|
|
return result
|
|
|
|
|
|
def _merge_data(self, hfive, paths):
|
|
|
- predata = np.zeros((2, 86400))
|
|
|
+ dim = len(self.pos_map)
|
|
|
+ predata = np.zeros((dim, 86400))
|
|
|
for path in paths:
|
|
|
predata += hfive[path]
|
|
|
return predata
|
|
|
|
|
|
def _calc_mratio(self,data,startes,end):
|
|
|
- all = data[0]
|
|
|
+ all = data[1] + data[2]
|
|
|
ySucc = data[1]
|
|
|
x = np.arange(0, 86400, 1)
|
|
|
|