Skip to content

Commit

Permalink
Similar_ids WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
d-fence committed Nov 14, 2024
1 parent a3310b5 commit bde8b6e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions runbot/models/build_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class BuildErrorContent(models.Model):
tag_ids = fields.Many2many('runbot.build.error.tag', string='Tags')
qualifiers = JsonDictField('Qualifiers', index=True)
qualifiers_search = fields.Char('Qualifiers ', store=False, search='_search_qualifiers')
similar_ids = fields.One2many('runbot.build.error.content', compute='_compute_similar_ids')

responsible = fields.Many2one(related='error_id.responsible')
customer = fields.Many2one(related='error_id.customer')
Expand Down Expand Up @@ -437,6 +438,21 @@ def _compute_error_display_id(self):
for error_content in self:
error_content.error_display_id = error_content.error_id.id

@api.depends('qualifiers')
def _compute_similar_ids(self):
for record in self:
if record.qualifiers:
query = SQL(
r"""SELECT id FROM runbot_build_error_content WHERE id != %s AND qualifiers @> %s AND qualifiers <@ %s""",
record.id,
json.dumps(self.qualifiers.dict),
json.dumps(self.qualifiers.dict),
)
self.env.cr.execute(query)
record.similar_ids = self.env['runbot.build.error.content'].browse([rec[0] for rec in self.env.cr.fetchall()])
else:
record.similar_ids = False

@api.model
def _digest(self, s):
"""
Expand Down Expand Up @@ -569,6 +585,7 @@ def action_search_qualified(self):
'domain': [('id', 'in', [rec[0] for rec in self.env.cr.fetchall()])],
}


class BuildErrorTag(models.Model):

_name = "runbot.build.error.tag"
Expand Down
15 changes: 15 additions & 0 deletions runbot/views/build_error_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@
</tree>
</field>
</page>
<page string="Similar">
<field name="similar_ids" widget="one2many" options="{'not_delete': True, 'no_create': True}" readonly="1">
<tree>
<field name="create_date"/>
<field name="module_name"/>
<field name="summary"/>
<field name="random"/>
<field name="build_count"/>
<field name="responsible"/>
<field name="fixing_commit"/>
<field name="id"/>
<button type="object" name="get_formview_action" icon="fa-arrow-right" title="View similar error"/>
</tree>
</field>
</page>
<page string="Debug" groups="base.group_no_one">
<group name="build_error_group">
<field name="fingerprint" readonly="1"/>
Expand Down

0 comments on commit bde8b6e

Please sign in to comment.