Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
oss
gitlabtime
Commits
75423dbd
Commit
75423dbd
authored
Aug 05, 2020
by
Thomas Lotze
Browse files
re
#2
: have month default to current month, include time range in report
parent
2bc04131
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/gitlabtime/cli.py
View file @
75423dbd
...
...
@@ -20,6 +20,8 @@ import click
@
click
.
option
(
'--month'
,
help
=
'Filter for month (yyyy-mm)'
,
default
=
date
.
today
().
isoformat
().
rsplit
(
'-'
,
1
)[
0
],
show_default
=
True
,
)
@
click
.
option
(
'--start'
,
...
...
@@ -50,17 +52,19 @@ def cli(url, token, month, start, end, project, username, csv):
first
=
date
.
fromisoformat
(
first
)
_
,
last
=
monthrange
(
first
.
year
,
first
.
month
)
end
=
'{}-{}'
.
format
(
month
,
last
)
filter
=
dict
(
start
=
start
,
end
=
end
,
project
=
project
,
username
=
username
,
)
entries
=
fetch
(
url
,
token
,
filter
)
if
csv
:
report_csv
(
entries
,
csv
)
report_csv
(
entries
,
csv
,
filter
)
else
:
report
(
entries
)
report
(
entries
,
filter
)
def
main
():
...
...
src/gitlabtime/report.py
View file @
75423dbd
...
...
@@ -4,7 +4,7 @@ from gitlab.v4.objects import ProjectMergeRequest
import
csv
def
report_csv
(
entries_by_project
,
csvpath
):
def
report_csv
(
entries_by_project
,
csvpath
,
filter
):
"""Print a report and create a CSV file.
"""
with
open
(
csvpath
,
'w'
,
newline
=
''
)
as
csvfile
:
...
...
@@ -25,12 +25,15 @@ def report_csv(entries_by_project, csvpath):
'Hours'
:
hours
,
})
report
(
entries_by_project
,
writerow
)
report
(
entries_by_project
,
filter
,
writerow
)
def
report
(
entries_by_project
,
writerow
=
lambda
*
args
:
None
):
def
report
(
entries_by_project
,
filter
,
writerow
=
lambda
*
args
:
None
):
"""Aggregate unordered sequences of time tracking entries into a report.
"""
print
(
'from {} to {}'
.
format
(
filter
[
'start'
],
filter
[
'end'
]))
print
()
total
=
sum
(
report_project
(
project
,
entries
,
writerow
)
for
project
,
entries
in
entries_by_project
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment