From b01ac1bfa667f278eef51dfeac28f11a8fe9bbc1 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 24 Jun 2020 09:22:53 -0400 Subject: [PATCH] add support to the bottleneck script for configuring history size --- awx/main/management/commands/bottleneck.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/awx/main/management/commands/bottleneck.py b/awx/main/management/commands/bottleneck.py index a9cc997a17..fec18c320f 100644 --- a/awx/main/management/commands/bottleneck.py +++ b/awx/main/management/commands/bottleneck.py @@ -12,14 +12,17 @@ class Command(BaseCommand): help='ID of the Job Template to profile') parser.add_argument('--threshold', dest='threshold', type=float, default=5, help='Only show tasks that took at least this many seconds (defaults to 5)') + parser.add_argument('--history', dest='history', type=float, default=25, + help='The number of historic jobs to look at') parser.add_argument('--ignore', action='append', help='ignore a specific action (e.g., --ignore git)') def handle(self, *args, **options): jt = options['jt'] threshold = options['threshold'] + history = options['history'] ignore = options['ignore'] - print('## ' + JobTemplate.objects.get(pk=jt).name + ' (last 25 runs)\n') + print('## ' + JobTemplate.objects.get(pk=jt).name + f' (last {history} runs)\n') with connection.cursor() as cursor: cursor.execute( f''' @@ -38,7 +41,7 @@ class Command(BaseCommand): SELECT unifiedjob_ptr_id FROM main_job WHERE job_template_id={jt} ORDER BY unifiedjob_ptr_id DESC - LIMIT 25 + LIMIT {history} ) ORDER BY delta DESC; '''