stanley-king 2 anos atrás
pai
commit
bacf30f00c

+ 1 - 1
plot/app.py

@@ -86,7 +86,7 @@ def mch_ratio():
         mchids = filter_mchids(mchids)
 
         painter = MerchantPainter(start_time=start_time, end_time=end_time, mchids=mchids, card_types=card_types, spec=spec, filter_wave=filter_wave)
-        buf = painter.paint()
+        buf = painter.paint_ratios()
         data = base64.b64encode(buf.getbuffer()).decode("ascii")
 
         return f"<img src='data:image/png;base64,{data}'/>"

+ 1 - 1
plot/plot_control.py

@@ -76,7 +76,7 @@ def mch_ratio():
         mchids = filter_mchids(mchids)
 
         painter = MerchantPainter(start_time=start_time, end_time=end_time, mchids=mchids, card_types=card_types, spec=spec, filter_wave=filter_wave)
-        buf = painter.paint()
+        buf = painter.paint_ratios()
         data = base64.b64encode(buf.getbuffer()).decode("ascii")
 
         return f"<img src='data:image/png;base64,{data}'/>"

+ 6 - 6
plot/refill/ChannelPainter.py

@@ -11,7 +11,7 @@ import time as time
 import logging
 logger = logging.getLogger('painter')
 
-def allpathes(reader: ChannelReader, tuple_pathes: dict, days: list, spec=None):
+def ratio_pathes(reader: ChannelReader, tuple_pathes: dict, days: list, spec=None):
     count = len(days)
     show_detail = True if len(list(tuple_pathes.keys())) == 1 else False
     if show_detail == False:
@@ -19,7 +19,7 @@ def allpathes(reader: ChannelReader, tuple_pathes: dict, days: list, spec=None):
     else:
         all_datas = None
 
-    for name, tup in tuple_pathes.items():
+    for mchid, tup in tuple_pathes.items():
         ch_datas = reader.init_data(count)
         for _card_type, _spec in tup:
             if spec is not None and _spec != spec:
@@ -31,7 +31,7 @@ def allpathes(reader: ChannelReader, tuple_pathes: dict, days: list, spec=None):
                 detail_datas = None
 
             for i, day in enumerate(days):
-                data = reader.read(day, name, _card_type, _spec)
+                data = reader.read(day, mchid, _card_type, _spec)
                 if data is not None:
                     column_pos = i * 86400
                     view = ch_datas[:, column_pos:column_pos + 86400]
@@ -41,10 +41,10 @@ def allpathes(reader: ChannelReader, tuple_pathes: dict, days: list, spec=None):
                         view = detail_datas[:, column_pos:column_pos + 86400]
                         view += data
             if show_detail:
-                yield name, _card_type, _spec, detail_datas
+                yield mchid, _card_type, _spec, detail_datas
         if all_datas is not None:
             all_datas += ch_datas
-        yield name, None, None, ch_datas
+        yield mchid, None, None, ch_datas
 
     if show_detail == False:
         yield 'all', None, None, all_datas
@@ -96,7 +96,7 @@ class ChannelPainter(object):
     def paint(self):
         reader = ChannelReader()
         tuple_pathes = reader.many_tuple_path(self._days, self._chnames, self._card_types, self._spec)
-        gen = allpathes(self._reader, tuple_pathes, self._days, self._spec)
+        gen = ratio_pathes(self._reader, tuple_pathes, self._days, self._spec)
         if len(self._days) == 0:
             return BytesIO()
 

+ 3 - 1
plot/refill/MerchantPainter.py

@@ -92,7 +92,7 @@ class MerchantPainter(object):
 
         return create, flush
 
-    def paint(self):
+    def paint_ratios(self):
         tuple_pathes = self._reader.many_tuple_path(self._days, self._mchids, self._card_types, self._spec)
         gen = allpathes(self._reader, tuple_pathes, self._days, self._spec)
         if len(self._days) == 0:
@@ -147,3 +147,5 @@ class MerchantPainter(object):
         lable += f":{succ}/{count}={ratio}%"
 
         return lable
+
+