From 1fd4d6c03cf7d83bf61770f9e6057f08b090edc5 Mon Sep 17 00:00:00 2001 From: Andrew Lee <1517745+andrewrlee@users.noreply.github.com> Date: Wed, 17 Apr 2024 08:44:44 +0100 Subject: [PATCH] Adding timezone info to published dates (#20) --- .env.example | 1 + health_ping.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 172bb52..b232e40 100644 --- a/.env.example +++ b/.env.example @@ -3,3 +3,4 @@ SERVICE_CATALOGUE_API_KEY= REDIS_ENDPOINT=localhost REDIS_PORT=6379 REDIS_TLS_ENABLED=false +SERVICE_CATALOGUE_FILTER=&filters[name][$contains]=book-a-prison-visit-staff-ui diff --git a/health_ping.py b/health_ping.py index e106fa1..6b7e7bf 100644 --- a/health_ping.py +++ b/health_ping.py @@ -1,6 +1,6 @@ #!/usr/bin/env python '''Health ping - fetches all /health and /info endpoints and stores the results in Redis''' -from datetime import datetime +from datetime import datetime, timezone import os import threading import logging @@ -44,7 +44,7 @@ def update_sc_component(c_id, data): def update_app_version(app_version, c_name, e_name): version_key = f'version:{c_name}:{e_name}' - version_data={'v': app_version, 'dateAdded': datetime.now().isoformat()} + version_data={'v': app_version, 'dateAdded': datetime.now(timezone.utc).isoformat()} try: # Get last entry to version stream last_entry_version = redis.xrevrange(version_key, max='+', min='-', count=1) @@ -70,8 +70,8 @@ def process_env(c_name, e_name, endpoint, endpoint_type, component): stream_key = f'{endpoint_type}:{c_name}:{e_name}' stream_data = {} stream_data.update({'url': endpoint}) - stream_data.update({'dateAdded': datetime.now().isoformat()}) - + stream_data.update({'dateAdded': datetime.now(timezone.utc).isoformat()}) + try: # Override default User-Agent other gets blocked by mod security. headers = {'User-Agent': 'hmpps-health-ping'}