Skip to content

Commit

Permalink
Add --project-id option to the 'entries' group
Browse files Browse the repository at this point in the history
The Time Entries API doesn't have filtering options, so I am filtering
the response client side. Not great, we'll see if there are other
options.

refs: #6
  • Loading branch information
zmoog committed Feb 3, 2023
1 parent 64fd771 commit 5d5f961
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 72 deletions.
56 changes: 28 additions & 28 deletions tests/cassettes/test_entries_group_by/test_group_by_tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ interactions:
response:
body:
string: !!binary |
H4sIAAAAAAAEA82Z3YrjNhTHX0X4thnQh+UP3W1nurDQ0sIUCl2WQRNrEm8c27XlTWdL36CFXpdC
r/oCfbI+Qo+deGxFqSeT2mYhN5FNIp3f+Z8vvf3JiSNH0ICEhHIc+gtnlxWbMpdLdVc/IQHhmAQL
Jy+y92qp94t+4DLuU1jWstw0a2mVJAvnPk4SeZ8oRzzIpFQLp9Sy0I5wKKbsCpMr6n1LqaBcMP4Z
xgJjp34ny61XuCsY+x6eRlUhdZylsBefwT9GqlwWcb5fcq6z7bZKY/0o0KskyXYol0UZpyuUPaA3
33zwkIyiQpWlKlGcwmelSo3yOFdJnCr4dS1XpSPeOvoxV6Ks8jyD7b5r1uFY9SNCsR9gD8MibCVL
k0dH6KKCs0n7YM2uu4Op4oMq7iKVKK2iu/r9vZmqEpYbw3uUMMYWTmV825mmb761Nv950THDAaUe
nYMZES4XhHRHO8WswWoyoy51B5i9jn98IqaKIivQMolVCoiAA4pLdJ/IdINkGgHI9xWwe4B3dLxV
t1pu8/EBHnnmHADdWUS3B4iHAB4YmwDJHPQMwZ0hNMsb5+BE5uOEg+c5YZMTRIH/jIyjqewyTj2n
m5wTZoSDy06fxLBgoXD9Zznh0OTEQjqE6tXHqlDoNl6lkK6+yqIqUUhWeg0xMV42efAOMvESMhrk
MsgsWsZJid6UZTV6NmtEhsPuhBPDCwIf8tl5IqMBdknI8EUFCAkEDwXvuaWdzA54TXY8rAskU2b/
/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K43dH68Bq+NrwjgXSTpxlaaRXqHMXpElU9b9UGX8dp
Gb6EXtYgCKHEFF0QXaQRJj0HHDvPuYJgAhV+CjyYSXeoEYbT1wRtPFSQXmx9EasCpNrXSa3kJPq+
hOkEjDoKtMjTDbrRSfQBXafFukwuT+jAy8YmRD3ieZMEEJOYDI+XCMyWQEYJmxBnbr/ZrSIFtDVM
mNK8KkZX6Fut1zADqkdE3ehoo7WB5/boKAiYgAL3tKhrN9QF/dg4YJbGPXFSwLS17LxaRAGFZEO9
D4g+mAQe0iBuEBzWItDPv6Evy2S+6sz/ifIZ/gzQ8730ekFLt5baLxyE+rwagY2fmajEUBYHJdgO
BrH9Hlyh5/fFQzLvbNwUhWrNMnczGiUnOHjzz9M5OPa48CapCJBs4POE3Ws0tt0pqSqWrbaWCtp3
GHCm217G/5cZpucdF/T7o4oJw2h6kvsEAvEMgmNoOEZ2jA4cvxq9HwJQlcalEsbM9W1C2RsxL1MV
H40CdkIUNNuYLAo8z2e0ur0ZPftg6P5cSQZ7joaTHQUB7uf5i2efnoeM7Pyeh6G+Qv06we4BxzQQ
VZN+xl0azLypL929ctbrFoAMfAi2zU6ZgOpvJx+TLpfxlcnVfC2hV4DLluqiBUGDkEd6r0ewasDT
Xt9uYBSvb623V3I9GHrgAOw5uvHrLpQP+TzwgTkDPhhYEeH3LsXGMn6zgemMz+Am+bS628ql8zxf
VHJnsOxWNbca3x54PnePCMs/fkGf51qtF9CRdcLnUz295xAXzDOttSxPJxga3wk8vbr7He6pwNg1
D9vYjAa98d5Ynt5ziAsa/zHNvP0bd0fgfDIhAAA=
headers:
Alt-Svc:
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Expand All @@ -50,7 +50,7 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- Fri, 03 Feb 2023 07:02:08 GMT
- Fri, 03 Feb 2023 07:48:05 GMT
Instance:
- time-public-api2
Referrer-Policy:
Expand All @@ -68,11 +68,11 @@ interactions:
X-Content-Type-Options:
- nosniff
X-Request-ID:
- fcc935dc52862c5105bcd3754c37f105
- 1012c9aa6eee4f312cfe0bf58f2b58cf
X-Service-Level:
- GREEN
X-Toggl-Request-Id:
- fcc935dc52862c5105bcd3754c37f105
- 1012c9aa6eee4f312cfe0bf58f2b58cf
X-We-are-hiring:
- https://toggl.com/jobs/
status:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-requests/2.28.2
method: GET
uri: https://api.track.toggl.com/api/v9/me/time_entries?start_date=2023-01-26T00%3A00%3A00Z&end_date=2023-01-27T00%3A00%3A00Z
response:
body:
string: !!binary |
H4sIAAAAAAAEA9WZ3Y7jNBTHX8XKLR3JH7GT+G6ZYaWVQCDNSkisViNP47bZpklInC2ziDdgJa4R
Ele8AE/GI3CSJpO6KZluacIg9aZO1Nrndz7+5/jNj04UOpL6JCCU48CbOds0XxeZmuu76gnxCcfE
nzlZnr7Tc7Nb9HyXcY/CslHFul5LyjieOfdRHKv7WDtyoeJCz5zCqNw40qGYsitMrqh4TamkXDL+
GcYSY6d6J816r3BXMvYdPA3LXJkoTWAvHoN/DHUxz6Nst+Rcp5tNmUTmQaIXcZxuUabyIkqWKF2g
V9+8F0iFYa6LQhcoSuCz1IVBWZTpOEo0/LpRy8KRbxzzkGlZlFmWwnbf1utwrOoRodjzscCwCFtJ
k/jBkSYv4Wyqf7B6193BdP5e53ehjrXR4V31/s5MZQHLteEFJYyxmVNa37a26etvrc1/mnXMsE+p
oFMwI9LlkpDuaMeY1VhtZtSl7gCzl9EPj8R0nqc5mseRTgARcEBRge5jlayRSkIA+a4Edgt4x0Qb
fWvUJrs8wAPPnAKgO0nQ7QDiIYANYxsg+T/Qo1eYvcaedIVkQXfEKeiR6ehhvztaP/wawDY9yA3/
mC+fTez9V/QwIxzce/yCh8Erpes9SQ8HNj0W0CGALz6UuUa30TKB0vZVGpax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3LsXGMn6zgemMz+Am+bS628ql8zxf
VHJnsOxWNbca3x54PnePCMs/fkGf51qtF9CRdcLnUz295xAXzDOttSxPJxga3wk8vbr7He6pwNg1
D9vYjAa98d5Ynt5ziAsa/zHNvP0bd0fgfDIhAAA=
headers:
Alt-Svc:
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Cache-Control:
- no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0
Content-Encoding:
- gzip
Content-Type:
- application/json; charset=utf-8
Date:
- Fri, 03 Feb 2023 07:48:05 GMT
Instance:
- time-public-api2
Referrer-Policy:
- strict-origin-when-cross-origin
Server:
- nginx
Strict-Transport-Security:
- max-age=15552000; includeSubDomains
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding
Via:
- 1.1 google
X-Content-Type-Options:
- nosniff
X-Request-ID:
- 3461241a983f5db01e7ae9f26b929aeb
X-Service-Level:
- GREEN
X-Toggl-Request-Id:
- 3461241a983f5db01e7ae9f26b929aeb
X-We-are-hiring:
- https://toggl.com/jobs/
status:
code: 200
message: OK
version: 1
56 changes: 28 additions & 28 deletions tests/cassettes/test_entries_list/test_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ interactions:
response:
body:
string: !!binary |
H4sIAAAAAAAEA82Z3YrjNhTHX0X4thnQh+UP3W1nurDQ0sIUCl2WQRNrEm8c27XlTWdL36CFXpdC
r/oCfbI+Qo+deGxFqSeT2mYhN5FNIp3f+Z8vvf3JiSNH0ICEhHIc+gtnlxWbMpdLdVc/IQHhmAQL
Jy+y92qp94t+4DLuU1jWstw0a2mVJAvnPk4SeZ8oRzzIpFQLp9Sy0I5wKKbsCpMr6n1LqaBcMP4Z
xgJjp34ny61XuCsY+x6eRlUhdZylsBefwT9GqlwWcb5fcq6z7bZKY/0o0KskyXYol0UZpyuUPaA3
33zwkIyiQpWlKlGcwmelSo3yOFdJnCr4dS1XpSPeOvoxV6Ks8jyD7b5r1uFY9SNCsR9gD8Mib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rgAOw5uvHrLpQP+TzwgTkDPhhYEeH3LsXGMn6zgemMz+Am+bS628ql8zxf
VHJnsOxWNbca3x54PnePCMs/fkGf51qtF9CRdcLnUz295xAXzDOttSxPJxga3wk8vbr7He6pwNg1
D9vYjAa98d5Ynt5ziAsa/zHNvP0bd0fgfDIhAAA=
headers:
Alt-Svc:
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Expand All @@ -50,7 +50,7 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- Fri, 03 Feb 2023 07:02:09 GMT
- Fri, 03 Feb 2023 07:48:05 GMT
Instance:
- time-public-api2
Referrer-Policy:
Expand All @@ -68,11 +68,11 @@ interactions:
X-Content-Type-Options:
- nosniff
X-Request-ID:
- a62a2f942c009e485790366413698216
- d37a26641b2eb9d772d2e2ad8364d785
X-Service-Level:
- GREEN
X-Toggl-Request-Id:
- a62a2f942c009e485790366413698216
- d37a26641b2eb9d772d2e2ad8364d785
X-We-are-hiring:
- https://toggl.com/jobs/
status:
Expand Down
26 changes: 26 additions & 0 deletions tests/test_entries_group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,29 @@ def test_group_by_tags():
"""
)


@pytest.mark.vcr
@pytest.mark.block_network
def test_group_by_tags_and_filter():
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(
cli,
["entries", "--project-id", "178435728", "group-by", "--field", "tags", "--start-date", "2023-01-26", "--end-date", "2023-01-27"],
env=env,
)
assert result.exit_code == 0
assert (
result.output
== """ Time Entries
tags Duration
─────────────────────────
type:support 5:44
type:sync 3:00
type:meeting 2:04
type:goal 0:35
"""
)
4 changes: 2 additions & 2 deletions tests/test_entries_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def test_list():
blank and
adjust for
timeStamp
2023-01-26 Community: Fix 09:45 PM 09:45 PM 0:00
2023-02-03 Community: Fix 09:45 PM 09:45 PM 0:00 type:support
parsing error
client port is
blank and
adjust for
timeStamp
2023-01-26 Community: Fix 09:45 PM 09:45 PM 0:00
2023-02-03 Community: Fix 09:45 PM 09:45 PM 0:00 type:support
parsing error
client port is
blank and
Expand Down
33 changes: 21 additions & 12 deletions toggl_track/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
from datetime import timedelta
import datetime as dt
from typing import List

import click

Expand All @@ -8,9 +8,9 @@


# default reference date for all date options
now = datetime.datetime.now()
now = dt.datetime.now()

def as_str(reference_date: datetime = now) -> str:
def as_str(reference_date: dt.datetime = now) -> str:
"""Formats a `reference_date` into a string.
Helper function to be used as a default value for click options.
Expand All @@ -26,31 +26,39 @@ def cli():


@cli.group()
def entries():
@click.option(
'--project-id',
'-p',
type=click.INT,
multiple=True)
@click.pass_context
def entries(ctx: click.Context, project_id: List[int]):
"Time entries commands"
pass
ctx.ensure_object(dict)
ctx.obj['project_id'] = project_id


@entries.command(name="list")
@click.option(
"--start-date",
type=click.DateTime(),
default=as_str(now - timedelta(hours=24)),
default=as_str(now - dt.timedelta(hours=24)),
help="Start date (default: 24 hours ago)"
)
@click.option(
"--end-date",
type=click.DateTime(),
default=as_str(now)
)
def list_entries(start_date: datetime, end_date: datetime):
@click.pass_context
def list_entries(ctx: click.Context, start_date: dt.datetime, end_date: dt.datetime):
"""Returns a list of the latest time entries (default: last 24 hours)"""

client = TimeEntries.from_environment()

click.echo(
TimeEntriesListResult(
client.list(start_date, end_date)
client.list(start_date, end_date, project_ids=ctx.obj['project_id'])
)
)

Expand All @@ -63,22 +71,23 @@ def list_entries(start_date: datetime, end_date: datetime):
@click.option(
"--start-date",
type=click.DateTime(),
default=as_str(now - timedelta(hours=24)),
default=as_str(now - dt.timedelta(hours=24)),
help="Start date (default: 24 hours ago)"
)
@click.option(
"--end-date",
type=click.DateTime(),
default=as_str(now)
)
def group_by_entries(start_date: datetime, end_date: datetime, field: str = "tags"):
@click.pass_context
def group_by_entries(ctx: click.Context, start_date: dt.datetime, end_date: dt.datetime, field: str = "tags"):
"""Returns a list of time entries grouped by a field"""

client = TimeEntries.from_environment()

click.echo(
TimeEntriesGroupByResult(
client.list(start_date, end_date),
client.list(start_date, end_date, project_ids=ctx.obj['project_id']),
key_func=GroupByCriterion(field)
)
)
2 changes: 2 additions & 0 deletions toggl_track/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __str__(self) -> str:

table = Table(title="Time Entries", box=box.SIMPLE)
table.add_column("At")
# table.add_column("Project")
table.add_column("Description")
table.add_column("Start")
table.add_column("Stop")
Expand All @@ -33,6 +34,7 @@ def __str__(self) -> str:
for e in self.entries:
table.add_row(
e.at.strftime("%Y-%m-%d"),
# str(e.project_id),
e.description,
e.start.strftime("%I:%M %p"),
"" if not e.stop else e.stop.strftime("%I:%M %p"),
Expand Down
Loading

0 comments on commit 5d5f961

Please sign in to comment.