Skip to main content

A simple hour tracker for git

Project description

%load_ext autoreload

%autoreload 2
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

Hourly

A simple hour tracker for git projects. hourly parses your commit messages for "clock in/out" keywords and uses their unix timestamps to precisely calculate work hours.

Getting Started

Install

pip install hourly

Requirements

pandas
gitpython

Usage

Hourly will look for key words for clocking in/out.

To clock in:

git commit -m "clock in - starting work on new feature"

do stuff as usual, then clock out

git commit -m "clock out - finished feature"

Tutorial

We can illustrate how to use hourly on the hourly repo itself.

git clone https://github.com/asherp/hourly.git
cd hourly
from hourly.hourly import get_work_commits, get_labor, get_earnings

get_work_commits gathers all commits into a pandas array

work = get_work_commits('.')
work
message
time
2018-10-19 23:40:41-04:00 Initial commit
2018-10-19 23:57:48-04:00 clock in\n
2018-10-20 00:21:40-04:00 preparing setup.py\n
2018-10-20 00:39:11-04:00 clock out - work done for the day\n
2018-10-20 01:06:08-04:00 clock in - start adding requirements and examp...
2018-10-20 01:47:01-04:00 clock out\n
2018-10-20 01:47:45-04:00 clock in - pro bono\n
2018-10-20 01:51:36-04:00 clock out - pro bono\n
2018-10-20 02:03:56-04:00 clock in - finishing tutorial\n
2018-10-20 02:11:54-04:00 clock out - converted notebook for README\n

get_labor calculates hours worked by differencing commit timestamps. *Note: get_labor raises an error if clock in and clock out are of different lengths *

Getting time card

get_labor(work)
pay period: 2018-10-19 23:57:48-04:00 -> 2018-10-20 02:11:54-04:00
TimeIn log in TimeOut log out TimeDelta
0 2018-10-19 23:57:48-04:00 clock in\n 2018-10-20 00:39:11-04:00 clock out - work done for the day\n 00:41:23
1 2018-10-20 01:06:08-04:00 clock in - start adding requirements and examp... 2018-10-20 01:47:01-04:00 clock out\n 00:40:53
2 2018-10-20 01:47:45-04:00 clock in - pro bono\n 2018-10-20 01:51:36-04:00 clock out - pro bono\n 00:03:51
3 2018-10-20 02:03:56-04:00 clock in - finishing tutorial\n 2018-10-20 02:11:54-04:00 clock out - converted notebook for README\n 00:07:58

Filtering work session keywords

Use the "ignore" key word to skip any work you don't want to include in your invoices.

labor = get_labor(work, ignore = 'pro bono')
labor
pay period: 2018-10-19 23:57:48-04:00 -> 2018-10-20 02:11:54-04:00
ignoring pro bono
TimeIn log in TimeOut log out TimeDelta
0 2018-10-19 23:57:48-04:00 clock in\n 2018-10-20 00:39:11-04:00 clock out - work done for the day\n 00:41:23
1 2018-10-20 01:06:08-04:00 clock in - start adding requirements and examp... 2018-10-20 01:47:01-04:00 clock out\n 00:40:53
3 2018-10-20 02:03:56-04:00 clock in - finishing tutorial\n 2018-10-20 02:11:54-04:00 clock out - converted notebook for README\n 00:07:58

Get total earnings

get_earnings(labor.TimeDelta)
0 days 01:30:14, 1.5038888888888888 hours worked
120.31 usd





120.31

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hourly-0.0.1.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distributions

hourly-0.0.1-py3.7.egg (5.6 kB view hashes)

Uploaded Source

hourly-0.0.1-py2.7.egg (5.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page