Skip to content

Commit dbe2ab6

Browse files
committed
Add Dispatch.end_time and print it in dispatch-cli
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 101f0aa commit dbe2ab6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

RELEASE_NOTES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Frequenz Dispatch Client Library Release Notes
22

3+
## Features
4+
5+
* `Dispatch.end_time` has been added to the `Dispatch` class, which is the time when the dispatch ended as calculated by the server. `dispatch-cli` will also print this time.
6+
37
## Bug Fixes
48

5-
* Fix that duration=0 was sent & received as None.
69
* Fix that `dispatch-cli stream` would try to print an event as dispatch, causing an exception.

src/frequenz/client/dispatch/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def format_line(key: str, value: str, color: str = "cyan") -> str:
148148
lines.append(format_line("Recurrence", "None"))
149149
lines.append(format_line("Create Time", format_datetime(dispatch.create_time)))
150150
lines.append(format_line("Update Time", format_datetime(dispatch.update_time)))
151+
lines.append(format_line("End Time", format_datetime(dispatch.end_time)))
151152

152153
# Combine all lines
153154
dispatch_info: str = "\n".join(lines)

src/frequenz/client/dispatch/types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ class Dispatch: # pylint: disable=too-many-instance-attributes
158158
update_time: datetime
159159
"""The last update time of the dispatch in UTC. Set when a dispatch is modified."""
160160

161+
end_time: datetime | None = None
162+
"""The end time of the dispatch in UTC.
163+
164+
Calculated and sent by the backend service.
165+
"""
166+
161167
@property
162168
def started(self) -> bool:
163169
"""Check if the dispatch has started.
@@ -290,6 +296,7 @@ def from_protobuf(cls, pb_object: PBDispatch) -> "Dispatch":
290296
type=pb_object.data.type,
291297
create_time=to_datetime(pb_object.metadata.create_time),
292298
update_time=to_datetime(pb_object.metadata.modification_time),
299+
end_time=to_datetime(pb_object.metadata.end_time),
293300
start_time=to_datetime(pb_object.data.start_time),
294301
duration=(
295302
timedelta(seconds=pb_object.data.duration)
@@ -317,6 +324,7 @@ def to_protobuf(self) -> PBDispatch:
317324
dispatch_id=self.id,
318325
create_time=to_timestamp(self.create_time),
319326
modification_time=to_timestamp(self.update_time),
327+
end_time=to_timestamp(self.end_time),
320328
),
321329
data=DispatchData(
322330
type=self.type,

0 commit comments

Comments
 (0)