From f4694e98dc6d168905c107ea5f3c11c532806007 Mon Sep 17 00:00:00 2001
From: Celeste Robert <celeste@lydra.fr>
Date: Wed, 7 May 2025 11:47:32 +0200
Subject: [PATCH 1/5] build: update dependencies

---
 pdm.lock | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/pdm.lock b/pdm.lock
index c07142b..7299c6d 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -46,16 +46,16 @@ files = [
 
 [[package]]
 name = "citric"
-version = "1.0.0"
+version = "1.4.0"
 requires_python = ">=3.8"
 summary = "A client to the LimeSurvey Remote Control API 2, written in modern Python."
 groups = ["default"]
 dependencies = [
-    "requests>=2.23",
+    "requests>=2.25.1",
 ]
 files = [
-    {file = "citric-1.0.0-py3-none-any.whl", hash = "sha256:89929562f81a574287e5d59564f0c564c77670da8b569eef5f5897eb9c6830aa"},
-    {file = "citric-1.0.0.tar.gz", hash = "sha256:a874928ee6416eadfe6ccca28b6eb38dc6fd938db4066f1ba5f272b9c7c7642d"},
+    {file = "citric-1.4.0-py3-none-any.whl", hash = "sha256:509bb9cf9800855dbc3ee01c5b0ce5d05c7c4e57bc7414cb685d4de3ff6ae37d"},
+    {file = "citric-1.4.0.tar.gz", hash = "sha256:34f3353768770ad7de8202f5efcca3eb1297af9915d9842f7d03d8e8497d58a4"},
 ]
 
 [[package]]
@@ -71,23 +71,23 @@ files = [
 
 [[package]]
 name = "python-dotenv"
-version = "1.0.1"
-requires_python = ">=3.8"
+version = "1.1.0"
+requires_python = ">=3.9"
 summary = "Read key-value pairs from a .env file and set them as environment variables"
 groups = ["default"]
 files = [
-    {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"},
-    {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"},
+    {file = "python_dotenv-1.1.0-py3-none-any.whl", hash = "sha256:d7c01d9e2293916c18baf562d95698754b0dbbb5e74d457c45d4f6561fb9d55d"},
+    {file = "python_dotenv-1.1.0.tar.gz", hash = "sha256:41f90bc6f5f177fb41f53e87666db362025010eb28f60a01c9143bfa33a2b2d5"},
 ]
 
 [[package]]
 name = "pytz"
-version = "2024.1"
+version = "2025.2"
 summary = "World timezone definitions, modern and historical"
 groups = ["default"]
 files = [
-    {file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"},
-    {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"},
+    {file = "pytz-2025.2-py2.py3-none-any.whl", hash = "sha256:5ddf76296dd8c44c26eb8f4b6f35488f3ccbf6fbbd7adee0b7262d43f0ec2f00"},
+    {file = "pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3"},
 ]
 
 [[package]]
-- 
GitLab


From bce6fa7521949a2b7619167cee727b47b6708b56 Mon Sep 17 00:00:00 2001
From: Celeste Robert <celeste@lydra.fr>
Date: Wed, 7 May 2025 12:13:37 +0200
Subject: [PATCH 2/5] feat: account timezone as parameter

---
 script.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/script.py b/script.py
index 25eeccc..60ca04d 100644
--- a/script.py
+++ b/script.py
@@ -11,6 +11,7 @@ parser.add_argument('-i', '--interval', metavar='N', type=int, help='Intervale m
 parser.add_argument('-r', '--reminders', metavar='N', type=int, help='Nombre de relances avant d’arrêter de relancer')
 parser.add_argument('-d', '--delay', metavar='N', type=int, help='Délai au-delà duquel on considère un vote comme abandonné')
 parser.add_argument('-e', '--expiry', type=datetime.datetime.fromisoformat, help='Date à partir de laquelle les relances du sondage sont terminées, format AAAA-mm-jj:HH:MM')
+parser.add_argument('-tz', '--timezone', metavar='N', type=int, help='Fuseau horaire. Entrer seulement le décalage en heures par rapport au fuseau UTC. Exemple: 2 pour l\'Europe/Paris, -4 pour New_York. Par défaut, le fuseau est UTC+2.')
 args = parser.parse_args()
 
 # Initialisation des variables
@@ -24,7 +25,7 @@ REMINDER_INTERVAL = args.interval or os.getenv('REMINDER_INTERVAL')
 REMINDERS = args.reminders or os.getenv('REMINDERS')
 OVER_DELAY = args.delay or os.getenv('OVER_DELAY')
 SURVEY_EXPIRATION_DATE = args.expiry or datetime.datetime.fromisoformat(os.getenv('SURVEY_EXPIRATION_DATE'))
-NOW = datetime.datetime.now() + datetime.timedelta(hours=int(2))
+NOW = datetime.datetime.now() + datetime.timedelta(hours=int(args.timezone or 0 if args.timezone == 0 else 2))
 
 # Initialisation du client remote control
 client = Client(f'{URL_API}/index.php/admin/remotecontrol', LOGIN, PASS)
-- 
GitLab


From 83004c1044b8df23867b45797d3916344c2d9122 Mon Sep 17 00:00:00 2001
From: Celeste Robert <celeste@lydra.fr>
Date: Wed, 7 May 2025 12:22:28 +0200
Subject: [PATCH 3/5] feat: logs into json file

---
 .gitignore |  1 +
 script.py  | 27 ++++++++++++++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/.gitignore b/.gitignore
index 37f7661..5460414 100644
--- a/.gitignore
+++ b/.gitignore
@@ -166,3 +166,4 @@ index.js
 node_modules
 package.json
 package-lock.json
+outputlogs.json
diff --git a/script.py b/script.py
index 60ca04d..83ae321 100644
--- a/script.py
+++ b/script.py
@@ -69,19 +69,20 @@ if SURVEY_EXPIRATION_DATE > NOW:
   participants = client.list_participants(FORM_ID, limit=100000, attributes=["remindersent","remindercount"])
   filtered_participants = list(filter(participant_overdue, participants))
 
-  for participant in filtered_participants:
-    reminder_count = participant['remindercount']
-    participant_id=int(participant['tid'])
-    if int(participant['remindercount']) < int(REMINDERS) :
-      if participant['remindersent'] == "N" or participant['remindersent'] == None or participant['remindersent'] == '':
-        print(f"{participant['participant_info']['email']} ({participant_id}), aucun rappel, {reminder_count}/{REMINDERS}")
-        mail_participant(participant_id)
-      else:
-        reminder = get_date(participant['remindersent'])
-        now = datetime.datetime.today().replace(microsecond=0) + datetime.timedelta(hours=int(2))
-        last_reminder = now - reminder
-        if reminder + datetime.timedelta(hours=int(REMINDER_INTERVAL)) < now:
-          print(f"{participant['participant_info']['email']} ({participant_id}), dernier rappel il y a {last_reminder}, {reminder_count}/{REMINDERS}")
+  with open('outputlogs.json', 'w') as f:
+    for participant in filtered_participants:
+      reminder_count = participant['remindercount']
+      participant_id=int(participant['tid'])
+      if int(participant['remindercount']) < int(REMINDERS) :
+        if participant['remindersent'] == "N" or participant['remindersent'] == None or participant['remindersent'] == '':
+          print(f"{participant['participant_info']['email']} ({participant_id}), aucun rappel, {reminder_count}/{REMINDERS}", file=f)
           mail_participant(participant_id)
+        else:
+          reminder = get_date(participant['remindersent'])
+          now = datetime.datetime.today().replace(microsecond=0) + datetime.timedelta(hours=int(2))
+          last_reminder = now - reminder
+          if reminder + datetime.timedelta(hours=int(REMINDER_INTERVAL)) < now:
+            print(f"{participant['participant_info']['email']} ({participant_id}), dernier rappel il y a {last_reminder}, {reminder_count}/{REMINDERS}", file=f)
+            mail_participant(participant_id)
 else:
   print('Sondage terminé')
-- 
GitLab


From 01bf6f626d42c610a7c1e882b833ad2626bb5ad1 Mon Sep 17 00:00:00 2001
From: Celeste Robert <celeste@lydra.fr>
Date: Tue, 13 May 2025 10:29:12 +0200
Subject: [PATCH 4/5] doc: documented logs and timezone parameter

---
 .gitlab-ci.yml |  7 +++++++
 CHANGELOG.md   | 10 +++++-----
 README.md      | 17 +++++++++++++++++
 pyproject.toml |  4 ++--
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b25957e..596d95d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,3 +18,10 @@ run_script:
     - pdm sync
   script:
     - pdm run vote_reminders
+
+output_file:
+  stage: deploy
+  artifacts:
+    paths:
+      - outputlogs.json
+    expire_in: 1 week
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17724e4..7654294 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,12 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 
-## [Unreleased]
-
-### Fixed
-
-- Consider timezone
+## [0.1.1] - 2025-05-13
 
+### Added
+- Add output logs file
+- Add timezone parameter
 
 ## [1.0.0] - 2024-06-04
 
@@ -27,3 +26,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Handle multiple datetime formats
 - Increase number of survey participants from 10k to 100k
+
diff --git a/README.md b/README.md
index 2fa45b1..d4ae31e 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,23 @@ Following parameters can only be passed to GitLab-CI:
 
 - `FREQ` : CI frequency
 
+### Setting the Timezone
+
+The default timezone is set to UTC+2. It will be used to compare correctly against the survey expiration date.
+
+The `--timezone` parameter can be used to set a different timezone. 
+The parameter is a number of hours to add to UTC to get the local timezone.
+
+For example, `--timezone 2` for Paris time, `--timezone -4` for New York time.
+
+### Output file
+
+The output file is a JSON file that contains all the execution logs.
+
+The file is saved as `outputlogs.json` and can be found in the root directory of the project when running the script localy and in the GitLab CI artifacts when running in GitLab.
+
+
+
 ## Documentation
 
 - https://manual.limesurvey.org/RemoteControl_2_API
diff --git a/pyproject.toml b/pyproject.toml
index 5b5b64f..fdd7c06 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,7 +1,7 @@
 [project]
 name = "vote_reminders"
-version = "0.1.0"
-description = "Default template for PDM package"
+version = "0.1.1"
+description = "Outil de rappel pour les sondages LimeSurvey"
 authors = [
     {name = "Plumtree3D", email = "celeste@lydra.fr"},
 ]
-- 
GitLab


From 11a8bc9162ef5461f87950ad2bde4c90fc1cc7f6 Mon Sep 17 00:00:00 2001
From: Celeste Robert <celeste@lydra.fr>
Date: Tue, 13 May 2025 10:47:03 +0200
Subject: [PATCH 5/5] fix: CI issue

---
 .gitlab-ci.yml | 3 ---
 CHANGELOG.md   | 2 +-
 pyproject.toml | 2 +-
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 596d95d..89bd776 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,9 +18,6 @@ run_script:
     - pdm sync
   script:
     - pdm run vote_reminders
-
-output_file:
-  stage: deploy
   artifacts:
     paths:
       - outputlogs.json
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7654294..149ffba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 
-## [0.1.1] - 2025-05-13
+## [1.1.0] - 2025-05-14
 
 ### Added
 - Add output logs file
diff --git a/pyproject.toml b/pyproject.toml
index fdd7c06..da82056 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [project]
 name = "vote_reminders"
-version = "0.1.1"
+version = "1.1.0"
 description = "Outil de rappel pour les sondages LimeSurvey"
 authors = [
     {name = "Plumtree3D", email = "celeste@lydra.fr"},
-- 
GitLab