Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Support joker characters at annotation filter #4306

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading