#1158 frontend: sort recent tasks after caching again
Merged 4 years ago by msuchy. Opened 4 years ago by praiskup.
Unknown source sort-recent-tasks  into  master

@@ -102,7 +102,7 @@

      def get_recent_tasks(cls, *args, **kwargs):

          task_ids = cls.get_recent_task_ids(*args, **kwargs)

          query = models.Build.query.filter(models.Build.id.in_(task_ids))

-         return list(query.all())

+         return sorted(query.all(), key=lambda o: task_ids.index(o.id))

  

      @classmethod

      def get_running_tasks_by_time(cls, start, end):

This can be sorted by orderby on sql server side.

Metadata Update from @praiskup:
- Pull-request tagged with: needs-work

4 years ago

Ah, now I recalled why python and not sql. ... we want to sort it according to the
"latest buildchroot ended_on time", not build_id. I.e. the list of build ids we use
in this query is already sorted... and so we want to have the list of builds sorted
acording to that. I've read [1] and I thought we are ok with python sort (there's
at most 100 builds anyways).

[1] https://stackoverflow.com/questions/23381644/how-to-order-data-in-sqlalchemy-by-list

Metadata Update from @praiskup:
- Pull-request untagged with: needs-work

4 years ago

rebased onto 45fc55a

4 years ago

Pull-Request has been merged by msuchy

4 years ago