зеркало из https://github.com/mozilla/treeherder.git
show new button for all failures on the same revision (#7555)
* show new button for all failures on the same revision * show new button for all failures on the same revision
This commit is contained in:
Родитель
30fc1210f2
Коммит
56b3aa161e
|
@ -49,6 +49,16 @@ def test_create_error_summary(
|
|||
|
||||
# We really need to add some tests that check the values of each entry
|
||||
# in bug_suggestions, but for now this is better than nothing.
|
||||
expected_keys = set(["search", "path_end", "search_terms", "bugs", "line_number", "counter"])
|
||||
expected_keys = set(
|
||||
[
|
||||
"search",
|
||||
"path_end",
|
||||
"search_terms",
|
||||
"bugs",
|
||||
"line_number",
|
||||
"counter",
|
||||
"failure_new_in_rev",
|
||||
]
|
||||
)
|
||||
for failure_line in bug_suggestions:
|
||||
assert set(failure_line.keys()) == expected_keys
|
||||
|
|
|
@ -69,6 +69,7 @@ def get_error_summary(job, queryset=None):
|
|||
logdate=job.submit_time,
|
||||
term_cache=term_cache,
|
||||
line_cache=line_cache,
|
||||
revision=job.push.revision,
|
||||
)
|
||||
error_summary.append(summary)
|
||||
|
||||
|
@ -87,7 +88,9 @@ def get_error_summary(job, queryset=None):
|
|||
return error_summary
|
||||
|
||||
|
||||
def bug_suggestions_line(err, project=None, logdate=None, term_cache=None, line_cache=None):
|
||||
def bug_suggestions_line(
|
||||
err, project=None, logdate=None, term_cache=None, line_cache=None, revision=None
|
||||
):
|
||||
"""
|
||||
Get Bug suggestions for a given TextLogError (err).
|
||||
|
||||
|
@ -106,7 +109,7 @@ def bug_suggestions_line(err, project=None, logdate=None, term_cache=None, line_
|
|||
else:
|
||||
today = str(logdate.date())
|
||||
if today not in line_cache.keys():
|
||||
line_cache[today] = {}
|
||||
line_cache[today] = {"new_lines": {}}
|
||||
|
||||
# remove the mozharness prefix
|
||||
clean_line = get_cleaned_line(err.line)
|
||||
|
@ -118,6 +121,10 @@ def bug_suggestions_line(err, project=None, logdate=None, term_cache=None, line_
|
|||
if project and str(project.name) in count_branches:
|
||||
if cache_clean_line not in line_cache[today].keys():
|
||||
line_cache[today][cache_clean_line] = 0
|
||||
if "new_lines" not in line_cache[today].keys():
|
||||
line_cache[today]["new_lines"] = {}
|
||||
if cache_clean_line not in line_cache[today]["new_lines"].keys():
|
||||
line_cache[today]["new_lines"][cache_clean_line] = revision
|
||||
line_cache[today][cache_clean_line] += 1
|
||||
|
||||
# get a meaningful search term out of the error line
|
||||
|
@ -149,6 +156,11 @@ def bug_suggestions_line(err, project=None, logdate=None, term_cache=None, line_
|
|||
for day in line_cache.keys():
|
||||
counter += line_cache[day].get(cache_clean_line, 0)
|
||||
|
||||
failure_new_in_rev = False
|
||||
if "new_lines" in line_cache[today] and cache_clean_line in line_cache[today]["new_lines"]:
|
||||
if revision == line_cache[today]["new_lines"][cache_clean_line]:
|
||||
failure_new_in_rev = True
|
||||
|
||||
# TODO: Rename 'search' to 'error_text' or similar, since that's
|
||||
# closer to what it actually represents (bug 1091060).
|
||||
return {
|
||||
|
@ -158,6 +170,7 @@ def bug_suggestions_line(err, project=None, logdate=None, term_cache=None, line_
|
|||
"bugs": bugs,
|
||||
"line_number": err.line_number,
|
||||
"counter": counter,
|
||||
"failure_new_in_rev": failure_new_in_rev,
|
||||
}, line_cache
|
||||
|
||||
|
||||
|
|
|
@ -1297,7 +1297,9 @@ class TextLogError(models.Model):
|
|||
def bug_suggestions(self):
|
||||
from treeherder.model import error_summary
|
||||
|
||||
return error_summary.bug_suggestions_line(self, self.job.repository)
|
||||
return error_summary.bug_suggestions_line(
|
||||
self, self.job.repository, revision=self.job.push.revision
|
||||
)
|
||||
|
||||
def create_match(self, matcher_name, classification):
|
||||
"""
|
||||
|
|
|
@ -80,6 +80,9 @@ class NoteViewSet(viewsets.ViewSet):
|
|||
"""
|
||||
current_job = Job.objects.get(repository__name=project, id=int(request.data['job_id']))
|
||||
fc_id = int(request.data['failure_classification_id'])
|
||||
revision = None
|
||||
if 'text' in request.data:
|
||||
revision = request.data['text']
|
||||
JobNote.objects.create(
|
||||
job=current_job,
|
||||
failure_classification_id=fc_id,
|
||||
|
@ -97,6 +100,12 @@ class NoteViewSet(viewsets.ViewSet):
|
|||
cache_clean_line = cache_clean_error_line(get_cleaned_line(err.line))
|
||||
if cache_clean_line in line_cache[date].keys():
|
||||
line_cache[date][cache_clean_line] -= 1
|
||||
if (
|
||||
cache_clean_line in line_cache[date]["new_lines"].keys()
|
||||
and revision
|
||||
and line_cache[date]["new_lines"][cache_clean_line] == revision
|
||||
):
|
||||
del line_cache[date]["new_lines"][cache_clean_line]
|
||||
try:
|
||||
cache.set(line_cache_key, line_cache, LINE_CACHE_TIMEOUT)
|
||||
except Exception as e:
|
||||
|
|
|
@ -155,7 +155,6 @@ class FailureSummaryTab extends React.Component {
|
|||
const jobLogsAllParsed =
|
||||
logs.length > 0 && logs.every((jlu) => jlu.parse_status !== 'pending');
|
||||
|
||||
let newButtonShown = false;
|
||||
let suggestionCounter = 0;
|
||||
suggestions.forEach((suggestion) => {
|
||||
suggestionCounter++;
|
||||
|
@ -163,11 +162,9 @@ class FailureSummaryTab extends React.Component {
|
|||
if (suggestionCounter < 2) {
|
||||
suggestion.showNewButton = false;
|
||||
if (
|
||||
!newButtonShown &&
|
||||
suggestion.search.split(' | ').length === 3 &&
|
||||
suggestion.counter === 1
|
||||
suggestion.failure_new_in_rev === true
|
||||
) {
|
||||
newButtonShown = true;
|
||||
suggestion.showNewButton = true;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче