Commit bdc1e1b9 authored by Thomas Lotze's avatar Thomas Lotze

re #3: filter for group name or path (actually, namespace)

parent 58adf1f3
......@@ -35,6 +35,10 @@ logging.basicConfig(format=logging.BASIC_FORMAT)
'--end',
help='Filter for end date (yyyy-mm-dd)',
)
@click.option(
'--group',
help='Filter for projects in group',
)
@click.option(
'--project',
help='Filter for project name',
......@@ -47,7 +51,7 @@ logging.basicConfig(format=logging.BASIC_FORMAT)
'--csv',
help='path to CSV output file',
)
def cli(url, token, month, start, end, project, username, csv):
def cli(url, token, month, start, end, group, project, username, csv):
if month:
first = month + '-01'
if not start:
......@@ -60,6 +64,7 @@ def cli(url, token, month, start, end, project, username, csv):
filter = dict(
start=start,
end=end,
group=group,
project=project,
username=username,
)
......
......@@ -15,6 +15,8 @@ def fetch(url, token, filter):
projects.sort(key=lambda p: p.path_with_namespace)
# We iterate over all projects regardless of our filter settings. When
# filtering for a group, we cannot list all groups first; if we try to do
# so, Gitlab will only return groups associated with the api token. When
# filtering for a project name, we have no better way of searching a
# project by name. When filtering for a user, we have no way at all of
# querying all notes authored by that user. As we want to catch all time
......@@ -29,6 +31,11 @@ def fetch(url, token, filter):
project.path_with_namespace,
None):
continue
if filter['group'] not in (
project.namespace['name'],
project.namespace['path'],
None):
continue
yield project, fetch_project(project, filter)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment