cli: list-task --after/--before/--all
allow querying for closed tasks Fixes: https://pagure.io/koji/issue/2565
This commit is contained in:
parent
812c1a804a
commit
0256282a84
3 changed files with 28 additions and 1 deletions
|
|
@ -6391,10 +6391,22 @@ def handle_list_tasks(goptions, session, args):
|
|||
parser.add_option("--host", help=_("Only tasks for this host"))
|
||||
parser.add_option("--quiet", action="store_true", default=goptions.quiet,
|
||||
help=_("Do not display the column headers"))
|
||||
parser.add_option("--before",
|
||||
help=_("List builds built before this time, "
|
||||
"time is specified as timestamp or date/time in any "
|
||||
"format which can be parsed by dateutil.parser. e.g. "
|
||||
"\"2020-12-31 12:35\" or \"December 31st 12:35\""))
|
||||
parser.add_option("--after",
|
||||
help=_("List builds built after this time (same format as for --before"))
|
||||
parser.add_option("--all", action="store_true",
|
||||
help=_("List also finished tasks (valid only with --after)"))
|
||||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 0:
|
||||
parser.error(_("This command takes no arguments"))
|
||||
|
||||
if options.all and not options.after:
|
||||
parser.error(_("--all must be used with --after"))
|
||||
|
||||
activate_session(session, goptions)
|
||||
tasklist = _list_tasks(options, session)
|
||||
if not tasklist:
|
||||
|
|
|
|||
|
|
@ -722,9 +722,14 @@ def _list_tasks(options, session):
|
|||
"Retrieve a list of tasks"
|
||||
|
||||
callopts = {
|
||||
'state': [koji.TASK_STATES[s] for s in ('FREE', 'OPEN', 'ASSIGNED')],
|
||||
'decode': True,
|
||||
}
|
||||
if not options.all:
|
||||
callopts['state'] = [koji.TASK_STATES[s] for s in ('FREE', 'OPEN', 'ASSIGNED')]
|
||||
if options.after:
|
||||
callopts['startedAfter'] = options.after
|
||||
if options.before:
|
||||
callopts['startedBefore'] = options.before
|
||||
|
||||
if getattr(options, 'mine', False):
|
||||
if getattr(options, 'user', None):
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ class TestListTasks(unittest.TestCase):
|
|||
options.method = None
|
||||
options.channel = None
|
||||
options.host = None
|
||||
options.before = None
|
||||
options.after = None
|
||||
options.all = False
|
||||
session = mock.MagicMock(name='session')
|
||||
session.getLoggedInUser.return_value = {'id': 1, 'username': 'name'}
|
||||
session.listTasks.return_value = []
|
||||
|
|
@ -259,4 +262,11 @@ Options:
|
|||
--channel=CHANNEL Only tasks in this channel
|
||||
--host=HOST Only tasks for this host
|
||||
--quiet Do not display the column headers
|
||||
--before=BEFORE List builds built before this time, time is specified as
|
||||
timestamp or date/time in any format which can be parsed
|
||||
by dateutil.parser. e.g. "2020-12-31 12:35" or "December
|
||||
31st 12:35"
|
||||
--after=AFTER List builds built after this time (same format as for
|
||||
--before
|
||||
--all List also finished tasks (valid only with --after)
|
||||
""" % self.progname)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue