Skip to content

Commit

Permalink
Merge pull request #61 from lcfd/issue-49
Browse files Browse the repository at this point in the history
[stop] Show the user the duration of the stopped session #49
  • Loading branch information
lcfd authored Apr 16, 2024
2 parents 6e39406 + f9f6edb commit bfde11d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cli/trakcli/tracker/commands/stop_tracker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from rich import print as rprint
from rich.panel import Panel

Expand All @@ -14,18 +15,25 @@ def stop_tracker():

record = tracking_already_started()

rprint("")
if isinstance(record, Record):
stopped_record = stop_trak_session()

# TODO: Show the user the duration of the stopped sessions
# https://github.com/lcfd/trak/issues/49
if stopped_record:
start_datetime = datetime.fromisoformat(stopped_record.start)
end_datetime = datetime.fromisoformat(stopped_record.end)
diff = end_datetime - start_datetime

all_minutes, _ = divmod(diff.seconds, 60)
h, m = divmod(all_minutes, 60)

rprint(
Panel.fit(
title="⏹️ Stop",
title="[bold green]⏹️ Stop[/bold green]",
renderable=print_with_padding(
(
f"The [bold green]{stopped_record.project}[/bold green] session is over.\n\n"
f"This session lasted [bold green]{h}h {m}m[/bold green].\n\n"
"Good job!"
)
),
Expand Down

0 comments on commit bfde11d

Please sign in to comment.