Skip to content

Commit

Permalink
[Fix] Add sorting feature and fix filter for testcase.
Browse files Browse the repository at this point in the history
The sorting feature was not available for the 'testcase' column since it first appeared in CodeChecker 6.22.2. The new PR gives a support to sort the reports on the Testcase column.

The testcase titles were truncated at the end in the filtering configuration modal if they were too long. In most cases, the unique part of the title is located at the end. The new modification allows the last part to remain intact while cutting characters at the beginning, similar to the filepath filter.

The testcase section of the report filter has listed all values from the report annotation table. With the new PR, those names appear only that belong to the given run and satisfy the filter conditions. It is also possible to search precisely for a testcase, similar to the filepath filter.
  • Loading branch information
cservakt committed Apr 16, 2024
1 parent 5228362 commit 72cd3d3
Show file tree
Hide file tree
Showing 14 changed files with 10,422 additions and 8,515 deletions.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion web/api/js/codechecker-api-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codechecker-api",
"version": "6.56.0",
"version": "6.57.0",
"description": "Generated node.js compatible API stubs for CodeChecker server.",
"main": "lib",
"homepage": "https://github.com/Ericsson/codechecker",
Expand Down
Binary file modified web/api/py/codechecker_api/dist/codechecker_api.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion web/api/py/codechecker_api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
with open('README.md', encoding='utf-8', errors="ignore") as f:
long_description = f.read()

api_version = '6.56.0'
api_version = '6.57.0'

setup(
name='codechecker_api',
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion web/api/py/codechecker_api_shared/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
with open('README.md', encoding='utf-8', errors="ignore") as f:
long_description = f.read()

api_version = '6.56.0'
api_version = '6.57.0'

setup(
name='codechecker_api_shared',
Expand Down
5 changes: 4 additions & 1 deletion web/api/report_server.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum SortType {
DETECTION_STATUS,
BUG_PATH_LENGTH,
TIMESTAMP,
TESTCASE
}

enum RunSortType {
Expand Down Expand Up @@ -613,7 +614,9 @@ service codeCheckerDBAccess {
// Get report annotation values belonging to the given key.
// The "key" parameter is optional. If not given then the list of keys returns.
// PERMISSION: PRODUCT_VIEW
list<string> getReportAnnotations(1: optional string key),
list<string> getReportAnnotations(2: list<i64> runIds,
3: ReportFilter reportFilter,
4: CompareData cmpData),

// Count the results separately for multiple runs.
// If an empty run id list is provided the report
Expand Down
2 changes: 1 addition & 1 deletion web/codechecker_web/shared/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The newest supported minor version (value) for each supported major version
# (key) in this particular build.
SUPPORTED_VERSIONS = {
6: 56
6: 57
}

# Used by the client to automatically identify the latest major and minor
Expand Down
46 changes: 37 additions & 9 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ def process_report_filter(
else:
OR.append(and_(
ReportAnnotations.key == key,
ReportAnnotations.value.in_(values)))
or_(*[ReportAnnotations.value.ilike(conv(v))
for v in values])) if values else and_(
ReportAnnotations.key == key))

AND.append(or_(*OR))

filter_expr = and_(*AND)
Expand Down Expand Up @@ -1001,7 +1004,8 @@ def get_sort_map(sort_types, is_unique=False):
SortType.SEVERITY: [(Checker.severity, 'severity')],
SortType.REVIEW_STATUS: [(Report.review_status, 'rw_status')],
SortType.DETECTION_STATUS: [(Report.detection_status, 'dt_status')],
SortType.TIMESTAMP: [('annotation_timestamp', 'annotation_timestamp')]}
SortType.TIMESTAMP: [('annotation_timestamp', 'annotation_timestamp')],
SortType.TESTCASE: [('annotation_testcase', 'annotation_testcase')]}

if is_unique:
sort_type_map[SortType.FILENAME] = [(File.filename, 'filename')]
Expand Down Expand Up @@ -2155,20 +2159,44 @@ def getRunResults(self, run_ids, limit, offset, sort_types,

@exc_to_thrift_reqfail
@timeit
def getReportAnnotations(self, key):
def getReportAnnotations(self, run_ids, report_filter, cmp_data):
self.__require_view()

with DBSession(self._Session) as session:
if key:
result = session \
.query(ReportAnnotations.value) \
filter_expression, join_tables = process_report_filter(
session, run_ids, report_filter, cmp_data)

extended_table = session.query(Report.id)

extended_table = apply_report_filter(
extended_table, filter_expression, join_tables)

if report_filter.annotations is not None:
extended_table = extended_table.outerjoin(
ReportAnnotations,
ReportAnnotations.report_id == Report.id)
extended_table = extended_table.group_by(Report.id)
extended_table = extended_table.add_columns(
ReportAnnotations.key.label('annotations_key'),
ReportAnnotations.value.label('annotations_value')
)

extended_table = extended_table.subquery()

result = session.query(extended_table.c.annotations_value) \
.distinct() \
.filter(ReportAnnotations.key == key) \
.filter(
*(extended_table.c.annotations_key == annotation.first
for annotation in report_filter.annotations)) \
.all()
else:
result = session \
.query(ReportAnnotations.key) \
extended_table = extended_table.subquery()

result = session.query(ReportAnnotations.value) \
.distinct() \
.join(
extended_table,
ReportAnnotations.report_id == extended_table.c.id) \
.all()

return list(map(lambda x: x[0], result))
Expand Down
Loading

0 comments on commit 72cd3d3

Please sign in to comment.