diff --git a/koseki/plugins/metric/metric.py b/koseki/plugins/metric/metric.py index 5fa7491..9ca86c6 100644 --- a/koseki/plugins/metric/metric.py +++ b/koseki/plugins/metric/metric.py @@ -83,9 +83,13 @@ def __calc_metric_payment(self) -> None: payments[0].registered.date(), datetime.min.time()) else: time = metrics[0].time + + metrics_idx : int = 0 while time <= datetime.now(): # Only insert the metric row if it doesn't already exist. - if sum(1 for metric in metrics if metric.time == time) == 0: + while metrics_idx < (len(metrics) - 1) and metrics[metrics_idx].time < time: + metrics_idx += 1 + if len(metrics) == 0 or metrics[metrics_idx].time != time: total: float = 0.0 for payment in payments: if payment.registered < time: diff --git a/requirements/common.txt b/requirements/common.txt index 2fbe1d6..e62156f 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -3,7 +3,7 @@ argon2-cffi>=20.1.0 email-validator>=1.1.2 flask-multistatic>=1.0 flask-wtf>=0.14.3 -flask>=1.1.2 +flask==1.1.2 libsass>=0.20.1 logging_prometheus>=0.1.0 lxml>=4.6.2 @@ -12,4 +12,5 @@ prometheus-flask-exporter>=0.18.1 pyop>=3.2.0 pyjwkest>=1.4.2 requests>=2.25.1 -SQLAlchemy>=1.4.15 \ No newline at end of file +SQLAlchemy==1.4.15 +markupsafe==2.0.1