From d440fa1fac4bf21d3e135fec08b981b14aee5c81 Mon Sep 17 00:00:00 2001 From: loganthomas Date: Sat, 29 Nov 2025 07:42:56 -0600 Subject: [PATCH 1/6] fix: bump2version --- .bumpversion.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c0cde74..5273a93 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -21,6 +21,6 @@ first_value = 1 search = version = "{current_version}" replace = version = "{new_version}" -[bumpversion:file:src/utt_balance/__init__.py] +[bumpversion:file:src/utt_project_summary/__init__.py] search = __version__ = "{current_version}" replace = __version__ = "{new_version}" From c816a23c4a2932436086af6dd4d10415e065d237 Mon Sep 17 00:00:00 2001 From: loganthomas Date: Sat, 29 Nov 2025 07:43:00 -0600 Subject: [PATCH 2/6] =?UTF-8?q?Bump=20version:=200.1.0-rc.1=20=E2=86=92=20?= =?UTF-8?q?0.1.0-rc.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- pyproject.toml | 2 +- src/utt_project_summary/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5273a93..75d63ca 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.0-rc.1 +current_version = 0.1.0-rc.2 commit = True tag_name = v{new_version} parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?Prc)\.(?P\d+))? diff --git a/pyproject.toml b/pyproject.toml index e731bd1..33dc0f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "utt-project-summary" -version = "0.1.0-rc.1" +version = "0.1.0-rc.2" description = "A utt plugin to show projects sorted by time spent" readme = "README.md" license = "GPL-3.0-only" diff --git a/src/utt_project_summary/__init__.py b/src/utt_project_summary/__init__.py index c0b911f..ff3bfb2 100644 --- a/src/utt_project_summary/__init__.py +++ b/src/utt_project_summary/__init__.py @@ -1,3 +1,3 @@ """utt-project-summary: A utt plugin to show projects sorted by time spent.""" -__version__ = "0.1.0-rc.1" +__version__ = "0.1.0-rc.2" From 1ad92f8f62121ce1cf23cd0d65a02ac7204acf90 Mon Sep 17 00:00:00 2001 From: loganthomas Date: Sat, 29 Nov 2025 07:51:11 -0600 Subject: [PATCH 3/6] doc: add badges to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 77b999f..518f895 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # utt-project-summary +[![CI - Test](https://github.com/loganthomas/utt-project-summary/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/loganthomas/utt-project-summary/actions/workflows/unit-tests.yml) +[![PyPI Latest Release](https://img.shields.io/pypi/v/utt-project-summary.svg)](https://pypi.org/project/utt-project-summary/) +[![PyPI Downloads](https://img.shields.io/pypi/dm/utt-project-summary.svg?label=PyPI%20downloads)](https://pypi.org/project/utt-project-summary/) +[![License - GPL-3.0](https://img.shields.io/pypi/l/utt-project-summary.svg)](https://github.com/loganthomas/utt-project-summary/blob/main/LICENSE) +[![Python Versions](https://img.shields.io/pypi/pyversions/utt-project-summary.svg)](https://pypi.org/project/utt-project-summary/) + A [`utt`](https://github.com/larose/utt) plugin that shows projects sorted by time spent. ## Why utt-project-summary? From 4cfc951dc786c33d4c65e734a3d7718b77d4f1d3 Mon Sep 17 00:00:00 2001 From: loganthomas Date: Sat, 29 Nov 2025 08:21:51 -0600 Subject: [PATCH 4/6] doc: add explicit main branch to ci badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 518f895..a2599e7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # utt-project-summary -[![CI - Test](https://github.com/loganthomas/utt-project-summary/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/loganthomas/utt-project-summary/actions/workflows/unit-tests.yml) +[![CI - Test](https://github.com/loganthomas/utt-project-summary/actions/workflows/unit-tests.yml/badge.svg?branch=main)](https://github.com/loganthomas/utt-project-summary/actions/workflows/unit-tests.yml) [![PyPI Latest Release](https://img.shields.io/pypi/v/utt-project-summary.svg)](https://pypi.org/project/utt-project-summary/) [![PyPI Downloads](https://img.shields.io/pypi/dm/utt-project-summary.svg?label=PyPI%20downloads)](https://pypi.org/project/utt-project-summary/) [![License - GPL-3.0](https://img.shields.io/pypi/l/utt-project-summary.svg)](https://github.com/loganthomas/utt-project-summary/blob/main/LICENSE) From 409574f5f57d71cf5ee9390fd0200745a072afce Mon Sep 17 00:00:00 2001 From: loganthomas Date: Fri, 19 Dec 2025 11:51:59 -0600 Subject: [PATCH 5/6] refactor: use pythonic patterns and improve column alignment --- .github/workflows/unit-tests.yml | 3 +- src/utt/plugins/project_summary.py | 45 ++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 611d709..f0c08df 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -4,6 +4,7 @@ on: push: branches: - dev + - main pull_request: jobs: @@ -34,5 +35,5 @@ jobs: - name: Run tests run: pytest - - name: Complete messsge + - name: Complete message run: echo "unit tests completed" diff --git a/src/utt/plugins/project_summary.py b/src/utt/plugins/project_summary.py index bc24041..7fa098b 100644 --- a/src/utt/plugins/project_summary.py +++ b/src/utt/plugins/project_summary.py @@ -9,6 +9,8 @@ from utt.api import _v1 +DEFAULT_CURRENT_ACTIVITY_NAME = "-- Current Activity --" + if TYPE_CHECKING: from collections.abc import Sequence @@ -85,10 +87,10 @@ def _aggregate_projects(self, activities: Sequence[_v1.Activity]) -> list[Projec def _extract_current(self, activities: Sequence[_v1.Activity]) -> CurrentActivity | None: """Extract current activity if present.""" - for activity in activities: - if activity.is_current_activity: - return CurrentActivity(activity.name.name, activity.duration) - return None + return next( + (CurrentActivity(a.name.name, a.duration) for a in activities if a.is_current_activity), + None, + ) def _compute_total(self) -> timedelta: """Sum all project durations plus current activity.""" @@ -101,9 +103,17 @@ def _compute_total(self) -> timedelta: class ProjectSummaryView: """Render project summary output.""" - def __init__(self, model: ProjectSummaryModel, show_perc: bool = False) -> None: + def __init__( + self, + model: ProjectSummaryModel, + show_perc: bool = False, + show_current: bool = True, + current_activity_name: str = DEFAULT_CURRENT_ACTIVITY_NAME, + ) -> None: self._model = model self._show_perc = show_perc + self._show_current = show_current + self._current_activity_name = current_activity_name def render(self, output: _v1.Output) -> None: """Render the project summary to output stream.""" @@ -112,7 +122,10 @@ def render(self, output: _v1.Output) -> None: print("---------------", file=output) print(file=output) - max_name_len = max((len(p.name) for p in self._model.projects), default=0) + project_names = [p.name for p in self._model.projects] + if self._show_current and self._model.current_activity: + project_names.append(self._current_activity_name) + max_name_len = max((len(name) for name in project_names), default=0) total_secs = self._model.total_duration.total_seconds() max_dur_len = 0 @@ -128,13 +141,13 @@ def render(self, output: _v1.Output) -> None: dur_str = f"{dur_str:<{max_dur_len}} ({perc:5.1f}%)" print(f"{project.name:<{max_name_len}}: {dur_str}", file=output) - if self._model.current_activity: + if self._show_current and self._model.current_activity: ca = self._model.current_activity dur_str = ca.formatted if self._show_perc and total_secs > 0: perc = (ca.duration.total_seconds() / total_secs) * 100 - dur_str = f"{dur_str} ({perc:5.1f}%)" - print(f"{ca.name:<{max_name_len}}: {dur_str}", file=output) + dur_str = f"{dur_str:<{max_dur_len}} ({perc:5.1f}%)" + print(f"{self._current_activity_name:<{max_name_len}}: {dur_str}", file=output) print(file=output) total_str = format_duration(self._model.total_duration) @@ -160,7 +173,13 @@ def __init__( def __call__(self) -> None: """Execute command.""" model = ProjectSummaryModel(self._activities) - ProjectSummaryView(model, self._args.show_perc).render(self._output) + view = ProjectSummaryView( + model, + show_perc=self._args.show_perc, + show_current=not self._args.no_current_activity, + current_activity_name=self._args.current_activity, + ) + view.render(self._output) def add_args(parser: argparse.ArgumentParser) -> None: @@ -176,9 +195,9 @@ def add_args(parser: argparse.ArgumentParser) -> None: ) parser.add_argument( "--current-activity", - default="-- Current Activity --", + default=DEFAULT_CURRENT_ACTIVITY_NAME, type=str, - help="Set the current activity", + help="Set the current activity name", ) parser.add_argument( "--no-current-activity", @@ -224,6 +243,8 @@ def add_args(parser: argparse.ArgumentParser) -> None: ) +# Note: type: ignore needed because _v1.Command expects a specific handler protocol +# that differs from our implementation's signature (uses filtered_activities vs activities) project_summary_command = _v1.Command( name="project-summary", description="Show projects sorted by time spent", From e0c88f18e362b3ac246ff5a9df47cf626ee3c961 Mon Sep 17 00:00:00 2001 From: loganthomas Date: Fri, 19 Dec 2025 11:55:53 -0600 Subject: [PATCH 6/6] fix(test): add missing Namespace attrs and revert column alignment --- src/utt/plugins/project_summary.py | 5 +---- tests/test_project_summary.py | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/utt/plugins/project_summary.py b/src/utt/plugins/project_summary.py index 7fa098b..9b4bae2 100644 --- a/src/utt/plugins/project_summary.py +++ b/src/utt/plugins/project_summary.py @@ -122,10 +122,7 @@ def render(self, output: _v1.Output) -> None: print("---------------", file=output) print(file=output) - project_names = [p.name for p in self._model.projects] - if self._show_current and self._model.current_activity: - project_names.append(self._current_activity_name) - max_name_len = max((len(name) for name in project_names), default=0) + max_name_len = max((len(p.name) for p in self._model.projects), default=0) total_secs = self._model.total_duration.total_seconds() max_dur_len = 0 diff --git a/tests/test_project_summary.py b/tests/test_project_summary.py index e8b059f..33e3971 100644 --- a/tests/test_project_summary.py +++ b/tests/test_project_summary.py @@ -445,7 +445,11 @@ def test_handler_renders_output(self): create_activity("backend: task1", datetime(2024, 1, 1, 9, 0), 120), create_activity("frontend: task1", datetime(2024, 1, 1, 11, 0), 60), ] - args = argparse.Namespace(show_perc=False) + args = argparse.Namespace( + show_perc=False, + no_current_activity=False, + current_activity="-- Current Activity --", + ) output = io.StringIO() handler = ProjectSummaryHandler(args, activities, output)