Change behaviour to issue placement worker to operate on oldest issues first

This is a follow up from !41313 (merged)

See:

!41313 (comment 407627129)

Currently there is an edge case where:

  • if there are more than QUERY_LIMIT issues that do not have a position
  • we take the most recent QUERY_LIMIT of them, and place them in creation order at the end
  • and then later, we repeat this, taking the next most recent, and place them in creation order at the end.

To illustrate (assuming QUERY_LIMIT=3):

key:
i = Unplaced issue
I = Placed issue

starting state (in creation order):

start state:
[I-a][I-b]     [i-c][i-d][i-e][i-f]
^--positioned  ^--unpositioned

Then we take the most recent 3 (d-f) and move them to the end of the positioned items, leaving the unpositioned ones at the end beyond that:

intermediate state:
[I-a][I-b][I-d][I-e][I-f]   [i-c]
^--positioned               ^--unpositioned

And then we repeat, moving the remaining unpositioned items to the end:

end state:
[I-a][I-b][I-d][I-e][I-f][I-c]
^--positioned

And we see that we have changed the order. Instead we should move the oldest three (c-e), and place them at the end of the set of positioned elements

intermediate state:
[I-a][I-b][I-c][I-d][I-e]   [i-f]
^--positioned               ^--unpositioned

And then we repeat, moving the remaining unpositioned items to the end:

end state:
[I-a][I-b][I-c][I-d][I-e][I-f]
^--positioned

Which preserves the order

Edited by Alex Kalderimis