Skip to content

Commit

Permalink
Start working with ttrack integration
Browse files Browse the repository at this point in the history
  • Loading branch information
luabida committed Jun 8, 2022
1 parent 564060f commit fdbc36f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.env*
__pycache__
.vscode/
data_test/.timetrackdb
34 changes: 34 additions & 0 deletions invoicex/ttrack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
import sqlite3
from humanfriendly import format_timespan
TTRACK_DB = 'data_test/.timetrackdb'
def _get_list_of_tasks_entries_with_time_in_seconds(sql_database):
conn = sqlite3.connect(sql_database)
cur = conn.cursor()
entries_with_seconds = []
for row in cur.execute(f"SELECT name, (end - start) FROM tasks AS T"
" INNER JOIN tasklog AS L ON T.id=L.task"
" ORDER BY name"):
entries_with_seconds.append(row)
return entries_with_seconds
def _isolate_same_tasks_in_list():
entries = _get_list_of_tasks_entries_with_time_in_seconds(TTRACK_DB)
same = {t:0 for t, s in entries}
for task, secs in entries:
same[task] += secs
result = list(map(tuple, same.items()))
return result
def _return_index_of_tasks_in_hours():
tasks = _isolate_same_tasks_in_list()
for t, s in tasks:
print(f'{t} ---- {format_timespan(s)}')
_return_index_of_tasks_in_hours()
"""
29 changes: 28 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ black = "^22.3.0"
flake8 = "^4.0.1"
isort = "^5.10.1"
pre-commit = "^2.18.1"
humanfriendly = "^10.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit fdbc36f

Please sign in to comment.