Merge pull request #12185 from AlexSCorey/8690-SortSchedulesByType

Adds sorting by type on the schedules list
This commit is contained in:
Alex Corey 2022-05-11 10:57:10 -04:00 committed by GitHub
commit 0787cb4fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 2 deletions

View File

@ -537,6 +537,7 @@ class ScheduleList(ListCreateAPIView):
name = _("Schedules")
model = models.Schedule
serializer_class = serializers.ScheduleSerializer
ordering = ('id',)
class ScheduleDetail(RetrieveUpdateDestroyAPIView):

View File

@ -166,7 +166,7 @@ function ScheduleList({
headerRow={
<HeaderRow qsConfig={QS_CONFIG}>
<HeaderCell sortKey="name">{t`Name`}</HeaderCell>
<HeaderCell>{t`Type`}</HeaderCell>
<HeaderCell sortKey="unified_job_template__polymorphic_ctype__model">{t`Type`}</HeaderCell>
<HeaderCell sortKey="next_run">{t`Next Run`}</HeaderCell>
<HeaderCell>{t`Actions`}</HeaderCell>
</HeaderRow>

View File

@ -4,6 +4,7 @@ users 500 5000 3 3 3 3 3 3 110
teams 200 500 2 2 2 2 2 2 100
projects 150 1000 30 30 30 30 30 30 110
job_templates 300 2000 127 127 127 127 127 127 110
schedules 50 1 5 8 1 1 1 1 1
credentials 150 2000 50 50 50 50 50 50 110
inventories 150 2000 6 6 6 6 6 6 110
inventory_groups 700 500 15 15 15 15 15 15 110
@ -12,4 +13,4 @@ wfjts 50 100 0 0 0 0 0 0 0
nodes 1000 1000 0 0 0 0 0 0 0
labels 1000 1000 0 0 0 0 0 0 0
jobs 2000 5000 157208 1000 10000 50000 100000 200000 1000
job_events 40000 100000 3370942 20000 200000 1000000 2000000 4000000 20000
job_events 40000 100000 3370942 20000 200000 1000000 2000000 4000000 20000

Can't render this file because it has a wrong number of fields in line 7.

View File

@ -53,6 +53,7 @@ from awx.main.models import ( # noqa
WorkflowJobTemplateNode,
batch_role_ancestor_rebuilding,
)
from awx.main.models.schedules import Schedule #noqa
from awx.main.signals import disable_activity_stream, disable_computed_fields # noqa
@ -63,6 +64,7 @@ option_list = [
make_option('--teams', action='store', type='int', default=5, help='Number of teams to create'),
make_option('--projects', action='store', type='int', default=10, help='Number of projects to create'),
make_option('--job-templates', action='store', type='int', default=20, help='Number of job templates to create'),
make_option('--schedules', action='store', type='int', default=50, help='Number of schedules to create'),
make_option('--credentials', action='store', type='int', default=5, help='Number of credentials to create'),
make_option('--inventories', action='store', type='int', default=5, help='Number of credentials to create'),
make_option('--inventory-groups', action='store', type='int', default=10, help='Number of credentials to create'),
@ -110,6 +112,7 @@ n_users = int(options['users'])
n_teams = int(options['teams'])
n_projects = int(options['projects'])
n_job_templates = int(options['job_templates'])
n_schedules = int(options['schedules'])
n_credentials = int(options['credentials'])
n_inventories = int(options['inventories'])
n_inventory_groups = int(options['inventory_groups'])
@ -126,6 +129,7 @@ users = []
teams = []
projects = []
job_templates = []
schedules = []
credentials = []
inventories = []
inventory_groups = []
@ -570,6 +574,29 @@ def make_the_data():
if n:
print('')
print('# Creating %d Schedules' % n_schedules)
jt_idx = 0
for n in spread(n_schedules, n_job_templates):
jt = job_templates[0]
for i in range(n):
ids['schedules'] += 1
schedules_id = ids['schedules']
unified_job_template = job_templates[jt_idx]
sys.stdout.write('\r Assigning %d to %s: %d ' % (n, jt, i + 1))
sys.stdout.flush()
schedule, _ = Schedule.objects.get_or_create(
name='%s Schedule %d' % (prefix, schedules_id),
rrule="DTSTART;TZID=America/New_York:20220505T111500 RRULE:INTERVAL=1;COUNT=1;FREQ=MINUTELY",
created_by=next(creator_gen),
modified_by=next(modifier_gen),
unified_job_template=unified_job_template,
)
schedule._is_new = _
schedules.append(schedule)
print('# Creating %d Labels' % n_labels)
org_idx = 0
for n in spread(n_labels, n_organizations):