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
2bc04131
Commit
2bc04131
authored
Aug 05, 2020
by
Thomas Lotze
Browse files
re
#2
: add filters for start and end date, fallback to month
parent
f55ef92c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/gitlabtime/cli.py
View file @
2bc04131
from
calendar
import
monthrange
from
datetime
import
date
from
gitlabtime.fetch
import
fetch
from
gitlabtime.report
import
report
from
gitlabtime.report
import
report_csv
...
...
@@ -19,6 +21,14 @@ import click
'--month'
,
help
=
'Filter for month (yyyy-mm)'
,
)
@
click
.
option
(
'--start'
,
help
=
'Filter for start date (yyyy-mm-dd)'
,
)
@
click
.
option
(
'--end'
,
help
=
'Filter for end date (yyyy-mm-dd)'
,
)
@
click
.
option
(
'--project'
,
help
=
'Filter for project name'
,
...
...
@@ -31,9 +41,18 @@ import click
'--csv'
,
help
=
'path to CSV output file'
,
)
def
cli
(
url
,
token
,
month
,
project
,
username
,
csv
):
def
cli
(
url
,
token
,
month
,
start
,
end
,
project
,
username
,
csv
):
if
month
:
first
=
month
+
'-01'
if
not
start
:
start
=
first
if
not
end
:
first
=
date
.
fromisoformat
(
first
)
_
,
last
=
monthrange
(
first
.
year
,
first
.
month
)
end
=
'{}-{}'
.
format
(
month
,
last
)
filter
=
dict
(
month
=
month
,
start
=
start
,
end
=
end
,
project
=
project
,
username
=
username
,
)
...
...
src/gitlabtime/fetch.py
View file @
2bc04131
...
...
@@ -39,7 +39,10 @@ def fetch_project(project, filter):
for
author
,
date
,
seconds
in
fetch_times
(
item
):
if
filter
[
'username'
]
not
in
(
author
,
None
):
continue
if
not
date
.
startswith
(
filter
[
'month'
]
or
''
):
if
(
filter
[
'start'
]
or
''
)
>
date
:
continue
if
(
filter
[
'end'
]
or
'9999-99-99'
)
<
date
:
continue
entries
[
author
,
date
]
+=
seconds
...
...
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