mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot_merge: stage by first ready
This is an approximation under the assumption that stored computes update the `write_date`, and that there's not much else that will be computed on a batch. Eventually it might be a good idea for this to be a proper field, computed alongside the unblocking of the batch. Fixes #932
This commit is contained in:
parent
146564a90a
commit
d0723499a2
@ -195,11 +195,15 @@ def ready_batches(for_branch: Branch) -> Tuple[bool, Batch]:
|
|||||||
# staged through priority *and* through split.
|
# staged through priority *and* through split.
|
||||||
split_ids = for_branch.split_ids.batch_ids.ids
|
split_ids = for_branch.split_ids.batch_ids.ids
|
||||||
env.cr.execute("""
|
env.cr.execute("""
|
||||||
SELECT max(priority)
|
SELECT exists (
|
||||||
FROM runbot_merge_batch
|
SELECT FROM runbot_merge_batch
|
||||||
WHERE blocked IS NULL AND target = %s AND NOT id = any(%s)
|
WHERE priority = 'alone'
|
||||||
|
AND blocked IS NULL
|
||||||
|
AND target = %s
|
||||||
|
AND NOT id = any(%s)
|
||||||
|
)
|
||||||
""", [for_branch.id, split_ids])
|
""", [for_branch.id, split_ids])
|
||||||
alone = env.cr.fetchone()[0] == 'alone'
|
[alone] = env.cr.fetchone()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
alone,
|
alone,
|
||||||
@ -208,7 +212,7 @@ def ready_batches(for_branch: Branch) -> Tuple[bool, Batch]:
|
|||||||
('blocked', '=', False),
|
('blocked', '=', False),
|
||||||
('priority', '=', 'alone') if alone else (1, '=', 1),
|
('priority', '=', 'alone') if alone else (1, '=', 1),
|
||||||
('id', 'not in', split_ids),
|
('id', 'not in', split_ids),
|
||||||
], order="priority DESC, id ASC"),
|
], order="priority DESC, write_date ASC, id ASC"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user