Retrieve n latest validation results
Signed-off-by: Jiri Podivin <jpodivin@redhat.com> Change-Id: Ie79062e85351ed545c33001866773bf38fdf8517
This commit is contained in:
parent
36c9b8cbcb
commit
a024978ece
|
@ -36,6 +36,12 @@ class ListHistory(Lister):
|
|||
metavar="<validation>",
|
||||
type=str,
|
||||
help='Display execution history for a validation')
|
||||
parser.add_argument('--limit',
|
||||
dest='history_limit',
|
||||
type=int,
|
||||
help=(
|
||||
'Display <n> most recent'
|
||||
'runs of <validation>'))
|
||||
parser.add_argument('--validation-log-dir', dest='validation_log_dir',
|
||||
default=constants.VALIDATIONS_LOG_BASEDIR,
|
||||
help=("Path where the validation log files "
|
||||
|
@ -44,7 +50,9 @@ class ListHistory(Lister):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
actions = ValidationActions(parsed_args.validation_log_dir)
|
||||
return actions.show_history(parsed_args.validation)
|
||||
return actions.show_history(
|
||||
validation_ids=parsed_args.validation,
|
||||
history_limit=parsed_args.history_limit)
|
||||
|
||||
|
||||
class GetHistory(Command):
|
||||
|
|
|
@ -500,7 +500,8 @@ class ValidationActions(object):
|
|||
return params
|
||||
|
||||
def show_history(self, validation_ids=None, extension='json',
|
||||
log_path=constants.VALIDATIONS_LOG_BASEDIR):
|
||||
log_path=constants.VALIDATIONS_LOG_BASEDIR,
|
||||
history_limit=None):
|
||||
"""Return validation executions history
|
||||
|
||||
:param validation_ids: The validation ids
|
||||
|
@ -559,10 +560,19 @@ class ValidationActions(object):
|
|||
validation_ids = [validation_ids]
|
||||
logs = []
|
||||
for validation_id in validation_ids:
|
||||
logs.extend(vlogs.get_logfile_by_validation(validation_id))
|
||||
logs.extend(
|
||||
vlogs.get_logfile_by_validation(
|
||||
validation_id))
|
||||
else:
|
||||
logs = vlogs.get_all_logfiles(extension)
|
||||
|
||||
if history_limit and history_limit >= len(logs):
|
||||
logs = sorted(
|
||||
[(os.stat(path).st_mtime, path) for path in logs],
|
||||
key=lambda path: path[0])
|
||||
|
||||
logs = [path[1] for path in logs[-history_limit:]]
|
||||
|
||||
values = []
|
||||
column_name = ('UUID', 'Validations',
|
||||
'Status', 'Execution at',
|
||||
|
|
Loading…
Reference in New Issue