From 4286395e83bc27f853f0919c988a716dc2b6a345 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 24 Feb 2022 23:30:23 +0100 Subject: Geodata redesign: context record, base find migration --- ishtar_common/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index fc302166b..a7e07ebde 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -2335,3 +2335,21 @@ def create_osm_town(rel_id, name, numero_insee=None): town.center = town.limit.centroid town.save() return town + + +def get_percent(current, total): + return f"{(current + 1) / total * 100:.1f}".rjust(4, "0") + "%" + + +def get_log_time(): + return datetime.datetime.now().isoformat().split(".")[0] + + +def get_eta(current, total, base_time, current_time): + if current < 5: + return "-" + elapsed_time = current_time - base_time + eta = elapsed_time.seconds / current * (total - current) + if eta < 1: + return "-" + return f"{int(eta // 3600):02d}:{int(eta % 3600 // 60):02d}:{int(eta % 60):02d}" -- cgit v1.2.3