From aae0b979347f37a96926fde33b9a4bc405bd09f8 Mon Sep 17 00:00:00 2001 From: MAURA Mathieu Date: Tue, 16 Jun 2026 02:23:08 +0200 Subject: [PATCH] . --- imapsync_daemon.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/imapsync_daemon.py b/imapsync_daemon.py index a83504b..5cdc556 100755 --- a/imapsync_daemon.py +++ b/imapsync_daemon.py @@ -130,7 +130,7 @@ NB_MAX_WORKERS = ( # Interval en minute minimum entre 2 vérification d'une meme BAL MIN_INTERVAL_MINUTES = 15 - +PRIORITY_INTERVAL_MINUTES = 2 TABLE_BALS = require_env("TABLE_BALS") COL_EMAIL = require_env("COL_EMAIL") @@ -266,7 +266,7 @@ def grist_fetch_new_bals() -> list[dict]: fields = r["fields"] # Récupération du timestamp Grist (ex: 1779124323.67) - last_pass_timestamp = fields.get("Date_derniere_passe") + last_pass_timestamp = fields.get(COL_LAST_PASS) # Si le timestamp existe, on valide l'écart de temps if last_pass_timestamp is not None: @@ -314,7 +314,7 @@ def grist_fetch_repass_bals() -> list[dict]: fields = r["fields"] # Récupération du timestamp Grist (ex: 1779124323.67) - last_pass_timestamp = fields.get("Date_derniere_passe") + last_pass_timestamp = fields.get(COL_LAST_PASS) # Si le timestamp existe, on valide l'écart de temps if last_pass_timestamp is not None: @@ -372,8 +372,19 @@ def grist_fetch_priority_bals() -> list[dict]: records = resp.json().get("records", []) filtered_bals = [] + current_timestamp = time.time() + for r in records: fields = r["fields"] + last_pass_timestamp = fields.get(COL_LAST_PASS) + + elapsed_time = current_timestamp - float(last_pass_timestamp) + if elapsed_time < PRIORITY_INTERVAL_MINUTES * 60: + log.debug( + f"BAL {r['id']} ignorée : passée il y a seulement {int(elapsed_time // 60)} min." + ) + continue + filtered_bals.append({"id": r["id"], **fields}) return filtered_bals