Skip to content

Commit

Permalink
almost similar hack
Browse files Browse the repository at this point in the history
  • Loading branch information
d-fence committed Nov 14, 2024
1 parent bde8b6e commit c571c35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions runbot/models/build_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ class BuildErrorContent(models.Model):
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')
almost_similar_count = fields.Integer(compute='_compute_almost_similar_count')

responsible = fields.Many2one(related='error_id.responsible')
customer = fields.Many2one(related='error_id.customer')
Expand Down Expand Up @@ -453,6 +454,14 @@ def _compute_similar_ids(self):
else:
record.similar_ids = False

@api.depends('qualifiers')
def _compute_almost_similar_count(self):
q = self.mapped('qualifiers')
qualifiers_read_group = self.env['runbot.build.error.content']._read_group([('qualifiers', 'in', q)], ['qualifiers'], ['__count'])
count_by_qualifiers = {tuple(sorted(qualifiers)): count - 1 for qualifiers, count in qualifiers_read_group}
for record in self:
self.almost_similar_count = count_by_qualifiers[tuple(sorted(record.qualifiers.dict))] if record.qualifiers else 0

@api.model
def _digest(self, s):
"""
Expand Down
4 changes: 4 additions & 0 deletions runbot/views/build_error_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
</group>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" name="action_search_qualified" type="object" icon="fa-binoculars">Find Similars</button>
<button class="oe_stat_button" name="action_search_qualified" type="object" icon="fa-thermometer-half">
<field name="almost_similar_count" class="o_stat_value"/>
<span class="o_stat_text">Almost Similars</span>
</button>
</div>
<group name="build_error_group" string="Base info" col="2">
<field name="content" readonly="1"/>
Expand Down

0 comments on commit c571c35

Please sign in to comment.