Skip to content

Commit 6a6110e

Browse files
committed
[IMP] vcp_management: Use cache to avoid launching cloc several times
1 parent 13d91db commit 6a6110e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

vcp_management/models/vcp_rule.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pathspec
88

9-
from odoo import fields, models
9+
from odoo import fields, models, tools
1010
from odoo.fields import Command
1111

1212
_logger = logging.getLogger(__name__)
@@ -44,7 +44,7 @@ def _process_rule_cloc(self, record):
4444
Process the rule as a cloc analysis.
4545
"""
4646
record._download_code()
47-
cloc_response = self._call_cloc_command(record.local_path)
47+
cloc_response = self.browse()._call_cloc_command(record.id, record.local_path)
4848
matches = self._cloc_get_matches(record.local_path)
4949
cloc_data = self._action_analysis_process_cloc(
5050
record.local_path, matches, cloc_response
@@ -94,7 +94,8 @@ def _action_analysis_process_cloc(self, path, matchs, cloc_response):
9494
res["empty"] += res_file["blank"]
9595
return res
9696

97-
def _call_cloc_command(self, local_path):
97+
@tools.ormcache("record_id", "local_path")
98+
def _call_cloc_command(self, record_id, local_path):
9899
res = check_output(["cloc", "--by-file", "--json", local_path])
99100
return json.loads(res)
100101

0 commit comments

Comments
 (0)