Skip to content

Commit bb0a602

Browse files
authored
Analytics: fix test_monitor script (#24173)
1 parent 18b50f8 commit bb0a602

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

.github/scripts/analytics/tests_monitor.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -375,37 +375,19 @@ def main():
375375
if result.result_set.rows and result.result_set.rows[0]['earliest_run']:
376376
earliest_run = result.result_set.rows[0]['earliest_run']
377377

378-
# Convert timestamp to datetime
379-
if earliest_run > 1000000000000000: # Microseconds
380-
timestamp_seconds = earliest_run / 1000000
381-
branch_creation_date = datetime.datetime.fromtimestamp(timestamp_seconds).date()
382-
print(f"Converted from microseconds: {branch_creation_date}")
383-
else: # Seconds or milliseconds
384-
if earliest_run > MICROSECONDS_THRESHOLD: # Microseconds
385-
timestamp_seconds = earliest_run / 1000000
386-
branch_creation_date = datetime.datetime.fromtimestamp(timestamp_seconds).date()
387-
print(f"Converted from microseconds: {branch_creation_date}")
388-
else: # Seconds or milliseconds
389-
if earliest_run > MILLISECONDS_THRESHOLD: # Milliseconds
390-
timestamp_seconds = earliest_run / 1000
391-
branch_creation_date = datetime.datetime.fromtimestamp(timestamp_seconds).date()
392-
print(f"Converted from milliseconds: {branch_creation_date}")
393-
else: # Seconds
394-
branch_creation_date = datetime.datetime.fromtimestamp(earliest_run).date()
395378
# Convert timestamp to datetime with error handling
396379
try:
397380
if earliest_run > 1000000000000000: # Microseconds
398381
timestamp_seconds = earliest_run / 1000000
399382
branch_creation_date = datetime.datetime.fromtimestamp(timestamp_seconds).date()
400383
print(f"Converted from microseconds: {branch_creation_date}")
401-
else: # Seconds or milliseconds
402-
if earliest_run > 1000000000000: # Milliseconds
403-
timestamp_seconds = earliest_run / 1000
404-
branch_creation_date = datetime.datetime.fromtimestamp(timestamp_seconds).date()
405-
print(f"Converted from milliseconds: {branch_creation_date}")
406-
else: # Seconds
407-
branch_creation_date = datetime.datetime.fromtimestamp(earliest_run).date()
408-
print(f"Converted from seconds: {branch_creation_date}")
384+
elif earliest_run > 1000000000000: # Milliseconds
385+
timestamp_seconds = earliest_run / 1000
386+
branch_creation_date = datetime.datetime.fromtimestamp(timestamp_seconds).date()
387+
print(f"Converted from milliseconds: {branch_creation_date}")
388+
else: # Seconds
389+
branch_creation_date = datetime.datetime.fromtimestamp(earliest_run).date()
390+
print(f"Converted from seconds: {branch_creation_date}")
409391
except (OSError, OverflowError, ValueError) as e:
410392
print(f"Error converting timestamp {earliest_run} to datetime: {e}")
411393
branch_creation_date = None

0 commit comments

Comments
 (0)