From 221b97343d5c8ca42962488a3ffb141dca87d43b Mon Sep 17 00:00:00 2001 From: Thilo Billerbeck Date: Wed, 4 Oct 2023 01:59:47 +0200 Subject: [PATCH] add toggl time grouper --- modules/packages.nix | 3 +++ pkgs/toggl-time-grouper/package.nix | 7 +++++++ pkgs/toggl-time-grouper/setup.py | 9 +++++++++ pkgs/toggl-time-grouper/toggl-time-grouper | 15 +++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 pkgs/toggl-time-grouper/package.nix create mode 100644 pkgs/toggl-time-grouper/setup.py create mode 100644 pkgs/toggl-time-grouper/toggl-time-grouper diff --git a/modules/packages.nix b/modules/packages.nix index a3b1acc..76f2f17 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -60,6 +60,9 @@ in { (callPackage ./../pkgs/docker-craft-cms-dev-env.nix { inherit lib; }) + (callPackage ./../pkgs/toggl-time-grouper/package.nix { + inherit lib; + }) (import (fetchTarball "https://github.com/cachix/devenv/archive/v0.6.2.tar.gz")).default nixpkgs-fmt diff --git a/pkgs/toggl-time-grouper/package.nix b/pkgs/toggl-time-grouper/package.nix new file mode 100644 index 0000000..140b8bd --- /dev/null +++ b/pkgs/toggl-time-grouper/package.nix @@ -0,0 +1,7 @@ +{ lib, python3Packages }: +with python3Packages; +buildPythonApplication { + name = "toggl-time-grouper"; + src = ./.; + propagatedBuildInputs = [ pandas ]; +} \ No newline at end of file diff --git a/pkgs/toggl-time-grouper/setup.py b/pkgs/toggl-time-grouper/setup.py new file mode 100644 index 0000000..11ab99f --- /dev/null +++ b/pkgs/toggl-time-grouper/setup.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +from distutils.core import setup + +setup( + name='toggl-time-grouper', + version='0.0.1', + scripts=['toggl-time-grouper'], +) \ No newline at end of file diff --git a/pkgs/toggl-time-grouper/toggl-time-grouper b/pkgs/toggl-time-grouper/toggl-time-grouper new file mode 100644 index 0000000..4f8373c --- /dev/null +++ b/pkgs/toggl-time-grouper/toggl-time-grouper @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import pandas as pd +import sys +from pathlib import Path + +df = pd.read_csv(sys.argv[1]) + +df = df.drop(columns=['User', 'Email', 'Billable', 'Tags', 'Amount ()', 'Start time', 'End date', 'End time']) +df['Duration'] = pd.to_timedelta(df['Duration']) +df['Start date'] = pd.to_datetime(df['Start date']) + +df = df.groupby(['Project','Description','Start date'])['Duration'].sum() + +df.to_csv(Path(sys.argv[1]).stem + '-grouped.csv') \ No newline at end of file