mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot_merge: add staging duration
Computed on the fly for now. Formatted nicely in the frontend, there does not seem to be any sort of duration widget in the backend so just display the integer number of seconds. Fixes #865
This commit is contained in:
parent
3f4519d605
commit
67f1c1e288
@ -1,6 +1,6 @@
|
||||
{
|
||||
'name': 'merge bot',
|
||||
'version': '1.12',
|
||||
'version': '1.13',
|
||||
'depends': ['contacts', 'mail', 'website'],
|
||||
'data': [
|
||||
'security/security.xml',
|
||||
|
4
runbot_merge/migrations/15.0.1.13/pre-migration.py
Normal file
4
runbot_merge/migrations/15.0.1.13/pre-migration.py
Normal file
@ -0,0 +1,4 @@
|
||||
def migrate(cr, version):
|
||||
cr.execute("ALTER TABLE runbot_merge_stagings "
|
||||
"ADD COLUMN staging_end timestamp without time zone")
|
||||
cr.execute("UPDATE runbot_merge_stagings SET staging_end = write_date")
|
@ -1796,6 +1796,8 @@ class Stagings(models.Model):
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
staged_at = fields.Datetime(default=fields.Datetime.now, index=True)
|
||||
staging_end = fields.Datetime()
|
||||
staging_duration = fields.Float(compute='_compute_duration')
|
||||
timeout_limit = fields.Datetime(store=True, compute='_compute_timeout_limit')
|
||||
reason = fields.Text("Reason for final state (if any)")
|
||||
|
||||
@ -1819,11 +1821,17 @@ class Stagings(models.Model):
|
||||
for staging in previously_pending:
|
||||
if staging.state != 'pending':
|
||||
super(Stagings, staging).write({
|
||||
'statuses_cache': json.dumps(staging.statuses)
|
||||
'staging_end': fields.Datetime.now(),
|
||||
'statuses_cache': json.dumps(staging.statuses),
|
||||
})
|
||||
|
||||
return True
|
||||
|
||||
@api.depends('staged_at', 'staging_end')
|
||||
def _compute_duration(self):
|
||||
for s in self:
|
||||
s.staging_duration = ((s.staging_end or fields.Datetime.now()) - s.staged_at).total_seconds()
|
||||
|
||||
def name_get(self):
|
||||
return [
|
||||
(staging.id, "%d (%s, %s%s)" % (
|
||||
|
@ -311,6 +311,8 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="staged_at"/>
|
||||
<field string="Staging Duration (seconds)"
|
||||
name="staging_duration" widget="integer"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
|
@ -24,7 +24,7 @@
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="true"
|
||||
t-attf-title="Staged at {{staging.staged_at}}Z"
|
||||
t-attf-title="Staged at {{staging.staged_at}}Z for {{round(staging.staging_duration)}}s"
|
||||
>
|
||||
<t t-out="0"/>
|
||||
<span class="caret"></span>
|
||||
@ -187,6 +187,11 @@
|
||||
</ul>
|
||||
<t t-call="runbot_merge.staging-statuses">
|
||||
Staged <span t-field="staging.staged_at" t-options="{'widget': 'relative'}"/>
|
||||
(duration <span t-field="staging.staging_duration" t-options="{
|
||||
'widget': 'duration',
|
||||
'format': 'short',
|
||||
'round': 'minute'
|
||||
}"/>)
|
||||
</t>
|
||||
</li>
|
||||
</t>
|
||||
@ -248,6 +253,11 @@
|
||||
<t t-call="runbot_merge.staging-statuses">
|
||||
<span t-field="staging.staged_at"
|
||||
t-options="{'format': 'yyyy-MM-dd\'T\'HH:mm:ssZ'}"/>
|
||||
in <span t-field="staging.staging_duration" t-options="{
|
||||
'widget': 'duration',
|
||||
'format': 'narrow',
|
||||
'round': 'minute'
|
||||
}"/>
|
||||
</t>
|
||||
</th>
|
||||
<td>
|
||||
|
Loading…
Reference in New Issue
Block a user