remove all traces about swimmers from seepark_web.py master
authorgregor herrmann <gregor@toastfreeware.priv.at>
Thu, 8 Sep 2022 22:42:44 +0000 (00:42 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Thu, 8 Sep 2022 22:42:44 +0000 (00:42 +0200)
web/seepark_web.py

index 48682d582af805b09c6e0046d07b023c3e969ed4..586d296bdd65a8a0d25ba30214d60b5b01e16d30 100644 (file)
@@ -192,32 +192,6 @@ def select_openweatherdata_grouped(cityid, begin, end):
     return query.all()
 
 
-def estimate_swimmer_count(date):
-    return None
-
-
-def select_swimmerdata(begin, end):
-    def report_times(begin, end):
-        d = begin
-        while d < end:
-            for t in [10, 15]:
-                a = datetime.datetime.combine(d.date(), datetime.time(t))
-                if a >= d:
-                    yield a
-            d += datetime.timedelta(days=1)
-    SwimmerData = collections.namedtuple('SwimmerData', ['datetime', 'count'])
-    for d in report_times(begin, end):
-        count = estimate_swimmer_count(d)
-        yield SwimmerData(d, count)
-
-
-def swimmerdata_to_xy(swimmerdata):
-    swimmerdata = list(swimmerdata)
-    x = np.array([d.datetime for d in swimmerdata])
-    y = np.array([d.count for d in swimmerdata])
-    return x, y
-
-
 def convert_to_c3(result, id, field_x, field_y):
     c3result = defaultdict(list)
     for row in result:
@@ -376,7 +350,6 @@ def report(year, month):
 
     water_data = sensordata_to_xy(select_sensordata(mainsensor, 'Wassertemperatur', begin, end))
     air_data = openweatherdata_to_xy(select_openweatherdata(cityid, begin, end))
-    swimmer_data = swimmerdata_to_xy(select_swimmerdata(begin, end))
 
     report_times = [datetime.time(10), datetime.time(15)]
     report_data = {'Wasser': water_data, 'Luft': air_data}
@@ -413,8 +386,6 @@ def report(year, month):
         for label in sorted(report_data.keys(), reverse=True):
             for t in report_times:
                 rows.append('{:02d}:{:02d} {} °C'.format(t.hour, t.minute, label))
-        for t in report_times:
-            rows.append('{:02d}:{:02d} Badende'.format(t.hour, t.minute))
         cells = []
         for label, data in sorted(report_data.items(), reverse=True):
             for t in report_times:
@@ -430,18 +401,6 @@ def report(year, month):
                         cell = '{:.1f}'.format(value)
                     row_cells.append(cell)
                 cells.append(row_cells)
-        for t in report_times:
-            row_cells = []
-            x, y = swimmer_data
-            for d in days_datetime:
-                report_datetime = datetime.datetime.combine(d.date(), t)
-                closest_index = np.argmin(np.abs(x - report_datetime))
-                if abs(x[closest_index] - report_datetime) > datetime.timedelta(hours=1):
-                    cell = 'N/A'
-                else:
-                    cell = y[closest_index]
-                row_cells.append(cell)
-            cells.append(row_cells)
         row_colors = list(ntimes(report_colors + ['w'], len(report_times)))
         table = plt.table(cellText=cells, colLabels=columns, rowLabels=rows, rowColours=row_colors, loc='bottom')
         table.scale(xscale=1, yscale=2)