mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Merge pull request #9738 from beeankha/update_schedule_sort
Enable ?page_size=1 to Fetch Correct Objects on JT Endpoint SUMMARY Problem: When multiple schedules are made from a single JT and a URL sort is done via: api/v2/job_templates/[id]/schedules/?page_size=1 ... the first half of the results come back with the same ID. 🤔 Solution: Implementing a backup sort via ID on the schedules model fixes this problem, and now all schedules on the job template endpoint are being fetched properly. ISSUE TYPE Bugfix Pull Request COMPONENT NAME API AWX VERSION awx: 18.0.0 ADDITIONAL INFORMATION This might fix #9632 Reviewed-by: Seth Foster <None> Reviewed-by: Rebeccah Hunter <rhunter@redhat.com>
This commit is contained in:
commit
94eeea6c33
18
awx/main/migrations/0135_schedule_sort_fallback_to_id.py
Normal file
18
awx/main/migrations/0135_schedule_sort_fallback_to_id.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.16 on 2021-03-29 15:30
|
||||
|
||||
from django.db import migrations
|
||||
import django.db.models.expressions
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0134_unifiedjob_ansible_version'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='schedule',
|
||||
options={'ordering': [django.db.models.expressions.OrderBy(django.db.models.expressions.F('next_run'), descending=True, nulls_last=True), 'id']},
|
||||
),
|
||||
]
|
||||
@ -63,7 +63,7 @@ class ScheduleManager(ScheduleFilterMethods, models.Manager):
|
||||
class Schedule(PrimordialModel, LaunchTimeConfig):
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
ordering = ['-next_run']
|
||||
ordering = [models.F('next_run').desc(nulls_last=True), 'id']
|
||||
unique_together = ('unified_job_template', 'name')
|
||||
|
||||
objects = ScheduleManager()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user