Skip to content

Commit 7ca5ce3

Browse files
authored
Show datetime in server compare (#1660)
1 parent 6b5616d commit 7ca5ce3

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

checks/remotesettings/server_compare.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
from telescope.typings import CheckResult
11-
from telescope.utils import run_parallel, utcnow
11+
from telescope.utils import run_parallel, utcfromtimestamp, utcnow
1212

1313
from .utils import KintoClient
1414

@@ -31,8 +31,18 @@ async def run(
3131
False,
3232
{
3333
"monitor/changes": {
34-
"source": source_entries[0]["last_modified"],
35-
"target": target_entries[0]["last_modified"],
34+
"source": {
35+
"timestamp": source_entries[0]["last_modified"],
36+
"datetime": utcfromtimestamp(
37+
source_entries[0]["last_modified"]
38+
).isoformat(),
39+
},
40+
"target": {
41+
"timestamp": target_entries[0]["last_modified"],
42+
"datetime": utcfromtimestamp(
43+
target_entries[0]["last_modified"]
44+
).isoformat(),
45+
},
3646
},
3747
},
3848
)
@@ -75,15 +85,21 @@ async def run(
7585

7686
if source_metadata_timestamp != target_metadata_timestamp:
7787
outdated["{bucket}/{collection}".format(**entry)] = {
78-
"source": source_metadata_timestamp,
79-
"target": target_metadata_timestamp,
88+
"source": {
89+
"timestamp": source_metadata_timestamp,
90+
"datetime": utcfromtimestamp(source_metadata_timestamp).isoformat(),
91+
},
92+
"target": {
93+
"timestamp": target_metadata_timestamp,
94+
"datetime": utcfromtimestamp(target_metadata_timestamp).isoformat(),
95+
},
8096
}
8197

8298
# Sort entries by source timestamp descending.
8399
outdated = dict(
84100
sorted(
85101
outdated.items(),
86-
key=lambda entry: entry[1]["source"],
102+
key=lambda entry: entry[1]["source"]["timestamp"],
87103
reverse=True,
88104
)
89105
)

tests/checks/remotesettings/test_server_compare.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,18 @@ async def test_negative(mock_aioresponses):
9797
status, data = await run(source_url, target_url)
9898

9999
assert status is False
100-
assert data == {"bid/cid": {"target": 123, "source": 456}}
100+
assert data == {
101+
"bid/cid": {
102+
"target": {
103+
"timestamp": 123,
104+
"datetime": "1970-01-01T00:00:00.123000+00:00",
105+
},
106+
"source": {
107+
"timestamp": 456,
108+
"datetime": "1970-01-01T00:00:00.456000+00:00",
109+
},
110+
}
111+
}
101112

102113

103114
async def test_negative_monitor_outdated(mock_aioresponses):
@@ -117,4 +128,9 @@ async def test_negative_monitor_outdated(mock_aioresponses):
117128
status, data = await run(source_url, target_url)
118129

119130
assert status is False
120-
assert data == {"monitor/changes": {"target": 41, "source": 42}}
131+
assert data == {
132+
"monitor/changes": {
133+
"target": {"timestamp": 41, "datetime": "1970-01-01T00:00:00.041000+00:00"},
134+
"source": {"timestamp": 42, "datetime": "1970-01-01T00:00:00.042000+00:00"},
135+
}
136+
}

0 commit comments

Comments
 (0)