Skip to content

Commit

Permalink
Merge pull request #4306 from bruntib/annotation_joker
Browse files Browse the repository at this point in the history
[fix] Support joker characters at annotation filter
  • Loading branch information
bruntib authored Aug 9, 2024
2 parents f85f771 + 1606a8e commit f7e9d53
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
9 changes: 6 additions & 3 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def process_report_filter(
if keep_all_annotations:
OR.append(or_(
ReportAnnotations.key != key,
ReportAnnotations.value.in_(values)))
*[ReportAnnotations.value.ilike(conv(v))
for v in values]))
else:
OR.append(and_(
ReportAnnotations.key == key,
Expand Down Expand Up @@ -2012,7 +2013,8 @@ def getRunResults(self, run_ids, limit, offset, sort_types,

OR = []
for key, values in annotations.items():
OR.append(annotation_cols[key].in_(values))
OR.extend([annotation_cols[key].ilike(conv(v))
for v in values])
sub_query = sub_query.having(or_(*OR))

sub_query = sort_results_query(sub_query,
Expand Down Expand Up @@ -2125,7 +2127,8 @@ def getRunResults(self, run_ids, limit, offset, sort_types,

OR = []
for key, values in annotations.items():
OR.append(annotation_cols[key].in_(values))
OR.extend([annotation_cols[key].ilike(conv(v))
for v in values])
q = q.having(or_(*OR))

q = q.limit(limit).offset(offset)
Expand Down
17 changes: 15 additions & 2 deletions web/tests/functional/dynamic_results/test_dynamic_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,25 @@ def test_filter_by_attribute(self):
results = self._cc_client.getRunResults(
None, 500, 0, None, testcase_filter, None, False)

self.assertEqual(len(results), 3)
self.assertEqual(len(results), 2)

self.assertTrue(all(map(
lambda report: report.annotations['testcase'] == 'TC-1',
results)))

testcase_filter = ReportFilter(annotations=[Pair(
first='testcase',
second='TC-*')])

results = self._cc_client.getRunResults(
None, 500, 0, None, testcase_filter, None, False)

self.assertEqual(len(results), 3)

self.assertTrue(all(map(
lambda report: report.annotations['testcase'].startswith('TC-'),
results)))

def test_count_by_attribute(self):
"""
Test the report count functions with the usage of report annotations.
Expand All @@ -156,4 +169,4 @@ def test_count_by_attribute(self):
num = self._cc_client.getRunResultCount(
None, testcase_filter, None)

self.assertEqual(num, 3)
self.assertEqual(num, 2)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<key>testcase</key>
<string>TS-1</string>
<key>testcase</key>
<string>TC-1</string>
<string>TC-2</string>
</dict>
<key>location</key>
<dict>
Expand Down

0 comments on commit f7e9d53

Please sign in to comment.