mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX runbot: remove _update_nb_children]
This commit is contained in:
parent
2b70c0bcc4
commit
acf31c2820
@ -120,7 +120,6 @@ class runbot_build(models.Model):
|
|||||||
|
|
||||||
@api.depends('children_ids.global_state', 'local_state', 'duplicate_id.global_state')
|
@api.depends('children_ids.global_state', 'local_state', 'duplicate_id.global_state')
|
||||||
def _compute_global_state(self):
|
def _compute_global_state(self):
|
||||||
# could we use nb_pending / nb_testing ? not in a compute, but in a update state method
|
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.duplicate_id:
|
if record.duplicate_id:
|
||||||
record.global_state = record.duplicate_id.global_state
|
record.global_state = record.duplicate_id.global_state
|
||||||
@ -172,23 +171,6 @@ class runbot_build(models.Model):
|
|||||||
def _get_result_score(self, result):
|
def _get_result_score(self, result):
|
||||||
return result_order.index(result)
|
return result_order.index(result)
|
||||||
|
|
||||||
def _update_nb_children(self, new_state, old_state=None):
|
|
||||||
# could be interresting to update state in batches.
|
|
||||||
tracked_count_list = ['pending', 'testing', 'running']
|
|
||||||
if (new_state not in tracked_count_list and old_state not in tracked_count_list) or new_state == old_state:
|
|
||||||
return
|
|
||||||
|
|
||||||
for record in self:
|
|
||||||
values = {}
|
|
||||||
if old_state in tracked_count_list:
|
|
||||||
values['nb_%s' % old_state] = record['nb_%s' % old_state] - 1
|
|
||||||
if new_state in tracked_count_list:
|
|
||||||
values['nb_%s' % new_state] = record['nb_%s' % new_state] + 1
|
|
||||||
|
|
||||||
record.write(values)
|
|
||||||
if record.parent_id:
|
|
||||||
record.parent_id._update_nb_children(new_state, old_state)
|
|
||||||
|
|
||||||
@api.depends('active_step', 'duplicate_id.active_step')
|
@api.depends('active_step', 'duplicate_id.active_step')
|
||||||
def _compute_job(self):
|
def _compute_job(self):
|
||||||
for build in self:
|
for build in self:
|
||||||
@ -209,7 +191,6 @@ class runbot_build(models.Model):
|
|||||||
return self.env['runbot.build']
|
return self.env['runbot.build']
|
||||||
vals['config_id'] = vals['config_id'] if 'config_id' in vals else branch.config_id.id
|
vals['config_id'] = vals['config_id'] if 'config_id' in vals else branch.config_id.id
|
||||||
build_id = super(runbot_build, self).create(vals)
|
build_id = super(runbot_build, self).create(vals)
|
||||||
build_id._update_nb_children(build_id.local_state)
|
|
||||||
extra_info = {'sequence': build_id.id if not build_id.sequence else build_id.sequence}
|
extra_info = {'sequence': build_id.id if not build_id.sequence else build_id.sequence}
|
||||||
context = self.env.context
|
context = self.env.context
|
||||||
|
|
||||||
@ -316,8 +297,6 @@ class runbot_build(models.Model):
|
|||||||
build_by_old_values = defaultdict(lambda: self.env['runbot.build'])
|
build_by_old_values = defaultdict(lambda: self.env['runbot.build'])
|
||||||
for record in self:
|
for record in self:
|
||||||
build_by_old_values[record.local_state] += record
|
build_by_old_values[record.local_state] += record
|
||||||
for local_state, builds in build_by_old_values.items():
|
|
||||||
builds._update_nb_children(values.get('local_state'), local_state)
|
|
||||||
assert 'state' not in values
|
assert 'state' not in values
|
||||||
local_result = values.get('local_result')
|
local_result = values.get('local_result')
|
||||||
for build in self:
|
for build in self:
|
||||||
|
@ -148,9 +148,6 @@
|
|||||||
</td>
|
</td>
|
||||||
<td t-if="build.real_build.children_ids">
|
<td t-if="build.real_build.children_ids">
|
||||||
Children:
|
Children:
|
||||||
<t t-if="build.real_build.nb_pending > 0"><t t-esc="build.real_build.nb_pending"/> pending </t>
|
|
||||||
<t t-if="build.real_build.nb_testing > 0"><t t-esc="build.real_build.nb_testing"/> testing </t>
|
|
||||||
<t t-if="build.real_build.nb_running > 0"><t t-esc="build.real_build.nb_running"/> running </t>
|
|
||||||
<table class="table table-condensed">
|
<table class="table table-condensed">
|
||||||
<t t-foreach="build.real_build.children_ids.sorted('id')" t-as="child">
|
<t t-foreach="build.real_build.children_ids.sorted('id')" t-as="child">
|
||||||
<t t-set="rowclass"><t t-call="runbot.build_class"><t t-set="build" t-value="child"/></t></t>
|
<t t-set="rowclass"><t t-call="runbot.build_class"><t t-set="build" t-value="child"/></t></t>
|
||||||
|
@ -327,62 +327,59 @@ class Test_Build(RunbotCase):
|
|||||||
'extra_params': '5',
|
'extra_params': '5',
|
||||||
})
|
})
|
||||||
|
|
||||||
def assert_state(nb_pending, nb_testing, nb_running, global_state, build):
|
def assert_state(global_state, build):
|
||||||
self.assertEqual(build.nb_pending, nb_pending)
|
|
||||||
self.assertEqual(build.nb_testing, nb_testing)
|
|
||||||
self.assertEqual(build.nb_running, nb_running)
|
|
||||||
self.assertEqual(build.global_state, global_state)
|
self.assertEqual(build.global_state, global_state)
|
||||||
|
|
||||||
assert_state(5, 0, 0, 'pending', build1)
|
assert_state('pending', build1)
|
||||||
assert_state(3, 0, 0, 'pending', build1_1)
|
assert_state('pending', build1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_2)
|
assert_state('pending', build1_2)
|
||||||
assert_state(1, 0, 0, 'pending', build1_1_1)
|
assert_state('pending', build1_1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_1_2)
|
assert_state('pending', build1_1_2)
|
||||||
|
|
||||||
build1.local_state = 'testing'
|
build1.local_state = 'testing'
|
||||||
build1_1.local_state = 'testing'
|
build1_1.local_state = 'testing'
|
||||||
build1.local_state = 'done'
|
build1.local_state = 'done'
|
||||||
build1_1.local_state = 'done'
|
build1_1.local_state = 'done'
|
||||||
|
|
||||||
assert_state(3, 0, 0, 'waiting', build1)
|
assert_state('waiting', build1)
|
||||||
assert_state(2, 0, 0, 'waiting', build1_1)
|
assert_state('waiting', build1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_2)
|
assert_state('pending', build1_2)
|
||||||
assert_state(1, 0, 0, 'pending', build1_1_1)
|
assert_state('pending', build1_1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_1_2)
|
assert_state('pending', build1_1_2)
|
||||||
|
|
||||||
build1_1_1.local_state = 'testing'
|
build1_1_1.local_state = 'testing'
|
||||||
|
|
||||||
assert_state(2, 1, 0, 'waiting', build1)
|
assert_state('waiting', build1)
|
||||||
assert_state(1, 1, 0, 'waiting', build1_1)
|
assert_state('waiting', build1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_2)
|
assert_state('pending', build1_2)
|
||||||
assert_state(0, 1, 0, 'testing', build1_1_1)
|
assert_state('testing', build1_1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_1_2)
|
assert_state('pending', build1_1_2)
|
||||||
|
|
||||||
build1_2.local_state = 'testing'
|
build1_2.local_state = 'testing'
|
||||||
|
|
||||||
assert_state(1, 2, 0, 'waiting', build1)
|
assert_state('waiting', build1)
|
||||||
assert_state(1, 1, 0, 'waiting', build1_1)
|
assert_state('waiting', build1_1)
|
||||||
assert_state(0, 1, 0, 'testing', build1_2)
|
assert_state('testing', build1_2)
|
||||||
assert_state(0, 1, 0, 'testing', build1_1_1)
|
assert_state('testing', build1_1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_1_2)
|
assert_state('pending', build1_1_2)
|
||||||
|
|
||||||
build1_2.local_state = 'testing' # writing same state a second time
|
build1_2.local_state = 'testing' # writing same state a second time
|
||||||
|
|
||||||
assert_state(1, 2, 0, 'waiting', build1)
|
assert_state('waiting', build1)
|
||||||
assert_state(1, 1, 0, 'waiting', build1_1)
|
assert_state('waiting', build1_1)
|
||||||
assert_state(0, 1, 0, 'testing', build1_2)
|
assert_state('testing', build1_2)
|
||||||
assert_state(0, 1, 0, 'testing', build1_1_1)
|
assert_state('testing', build1_1_1)
|
||||||
assert_state(1, 0, 0, 'pending', build1_1_2)
|
assert_state('pending', build1_1_2)
|
||||||
|
|
||||||
build1_1_2.local_state = 'done'
|
build1_1_2.local_state = 'done'
|
||||||
build1_1_1.local_state = 'done'
|
build1_1_1.local_state = 'done'
|
||||||
build1_2.local_state = 'done'
|
build1_2.local_state = 'done'
|
||||||
|
|
||||||
assert_state(0, 0, 0, 'done', build1)
|
assert_state('done', build1)
|
||||||
assert_state(0, 0, 0, 'done', build1_1)
|
assert_state('done', build1_1)
|
||||||
assert_state(0, 0, 0, 'done', build1_2)
|
assert_state('done', build1_2)
|
||||||
assert_state(0, 0, 0, 'done', build1_1_1)
|
assert_state('done', build1_1_1)
|
||||||
assert_state(0, 0, 0, 'done', build1_1_2)
|
assert_state('done', build1_1_2)
|
||||||
|
|
||||||
def test_duplicate_childrens(self):
|
def test_duplicate_childrens(self):
|
||||||
build_old = self.create_build({
|
build_old = self.create_build({
|
||||||
@ -406,8 +403,6 @@ class Test_Build(RunbotCase):
|
|||||||
self.assertEqual(build_child.local_state, 'duplicate')
|
self.assertEqual(build_child.local_state, 'duplicate')
|
||||||
self.assertEqual(build_child.duplicate_id, build_old)
|
self.assertEqual(build_child.duplicate_id, build_old)
|
||||||
self.assertEqual(build_child.global_state, 'done')
|
self.assertEqual(build_child.global_state, 'done')
|
||||||
self.assertEqual(build_parent.nb_pending, 0)
|
|
||||||
self.assertEqual(build_parent.nb_testing, 0)
|
|
||||||
self.assertEqual(build_parent.global_state, 'done')
|
self.assertEqual(build_parent.global_state, 'done')
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
<field name="last_success" readonly='1'/>
|
<field name="last_success" readonly='1'/>
|
||||||
<field name="assigned_only"/>
|
<field name="assigned_only"/>
|
||||||
<field name="nb_worker"/>
|
<field name="nb_worker"/>
|
||||||
<field name="nb_testing"/>
|
|
||||||
<field name="nb_running"/>
|
|
||||||
<field name="last_exception" readonly='1'/>
|
<field name="last_exception" readonly='1'/>
|
||||||
<field name="exception_count" readonly='1'/>
|
<field name="exception_count" readonly='1'/>
|
||||||
</group>
|
</group>
|
||||||
|
Loading…
Reference in New Issue
Block a user