mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: add a deduplicate server action
Duplicate error content should not happens ... but it does. With this commit, a server actions allows to relink error contents and thus removes error contents having the same fingerprint.
This commit is contained in:
parent
3a485536fd
commit
9d5b31fe18
@ -39,4 +39,14 @@
|
|||||||
records.action_assign()
|
records.action_assign()
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.actions.server" id="action_deduplicate">
|
||||||
|
<field name="name">Deduplicate Error Contents</field>
|
||||||
|
<field name="model_id" ref="runbot.model_runbot_build_error_content" />
|
||||||
|
<field name="binding_model_id" ref="runbot.model_runbot_build_error_content" />
|
||||||
|
<field name="type">ir.actions.server</field>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">
|
||||||
|
records.action_deduplicate()
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -486,6 +486,11 @@ class BuildErrorContent(models.Model):
|
|||||||
if not error.error_content_ids:
|
if not error.error_content_ids:
|
||||||
base_error._merge(error)
|
base_error._merge(error)
|
||||||
|
|
||||||
|
def _get_duplicates(self):
|
||||||
|
""" returns a list of lists of duplicates"""
|
||||||
|
domain = [('id', 'in', self.ids)] if self else []
|
||||||
|
return [r['id_arr'] for r in self.env['runbot.build.error.content'].read_group(domain, ['id_count:count(id)', 'id_arr:array_agg(id)', 'fingerprint'], ['fingerprint']) if r['id_count'] >1]
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Actions
|
# Actions
|
||||||
####################
|
####################
|
||||||
@ -521,8 +526,13 @@ class BuildErrorContent(models.Model):
|
|||||||
for errors_content_to_merge in to_merge:
|
for errors_content_to_merge in to_merge:
|
||||||
errors_content_to_merge._relink()
|
errors_content_to_merge._relink()
|
||||||
|
|
||||||
|
def action_deduplicate(self):
|
||||||
|
rg = self._get_duplicates()
|
||||||
|
for ids_list in rg:
|
||||||
|
self.env['runbot.build.error.content'].browse(ids_list)._relink()
|
||||||
|
|
||||||
def action_find_duplicates(self):
|
def action_find_duplicates(self):
|
||||||
rg = [r['id_arr'] for r in self.env['runbot.build.error.content'].read_group([], ['id_count:count(id)', 'id_arr:array_agg(id)', 'fingerprint'], ['fingerprint']) if r['id_count'] >1]
|
rg = self._get_duplicates()
|
||||||
duplicate_ids = []
|
duplicate_ids = []
|
||||||
for ids_lists in rg:
|
for ids_lists in rg:
|
||||||
duplicate_ids += ids_lists
|
duplicate_ids += ids_lists
|
||||||
|
Loading…
Reference in New Issue
Block a user