Skip to content

Commit

Permalink
Refactoring report filter UI
Browse files Browse the repository at this point in the history
* Create separate files for each base filters.
* Create new filter interface.
* Extend API with tag filter.
* Remove `CountFilter` type. The client should set the correct filter
set instead of checking the filter type.
* Do not show default values in URL query parameter for `is-unique`
and `difftype`.
* Notify other filters on filter change when users changed the filter
and the tooltip is closed.
* Get items from the server only if some filter is changed or if the
filter uses server side search.
  • Loading branch information
csordasmarton committed Mar 6, 2018
1 parent fd2df38 commit f0708f5
Show file tree
Hide file tree
Showing 24 changed files with 1,953 additions and 2,169 deletions.
15 changes: 13 additions & 2 deletions api/v6/report_server.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,20 @@ struct RunHistoryData {
2: string runName, // Name of the run.
3: string versionTag, // Version tag of the report.
4: string user, // User name who analysed the run.
5: string time // Date time when the run was analysed.
5: string time, // Date time when the run was analysed.
6: i64 id, // Id of the run history tag.
}
typedef list<RunHistoryData> RunHistoryDataList

/**
* Members of this struct are interpreted in "AND" relation with each other.
* Between the list elements there is "OR" relation.
* If exactMatch field is True it will use exact match for run names.
*/
struct RunHistoryFilter {
1: list<string> tagNames, // Part of the tag names.
}

struct RunTagCount {
1: string time, // Date time of the last run.
2: string name, // Name of the tag.
Expand Down Expand Up @@ -253,7 +263,8 @@ service codeCheckerDBAccess {
// PERMISSION: PRODUCT_ACCESS
RunHistoryDataList getRunHistory(1: list<i64> runIds,
2: i64 limit,
3: i64 offset)
3: i64 offset,
4: RunHistoryFilter runHistoryFilter)
throws (1: shared.RequestFailed requestError),

// Returns report hashes based on the diffType parameter.
Expand Down
84 changes: 29 additions & 55 deletions libcodechecker/server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@
LOG = get_logger('server')


class CountFilter:
FILE = 0
CHECKER_MSG = 1
CHECKER_NAME = 2
SEVERITY = 3
REVIEW_STATUS = 4
DETECTION_STATUS = 5
RUN_HISTORY_TAG = 6


class DBSession(object):
"""
Requires a session maker object and creates one session which can be used
Expand Down Expand Up @@ -110,13 +100,9 @@ def conv(text):
return text.replace('*', '%')


def process_report_filter_v2(session, report_filter, count_filter=None):
def process_report_filter(session, report_filter):
"""
Process the new report filter.
If the count_filter parameter is set it will ignore that field type of
the report_filter.
E.g.: If counter_filter is equal with Severity, it will ignore severity
field values of the report_filter.
"""

if report_filter is None:
Expand All @@ -134,8 +120,7 @@ def process_report_filter_v2(session, report_filter, count_filter=None):
for cm in report_filter.checkerMsg]
AND.append(or_(*OR))

if report_filter.checkerName is not None and \
count_filter != CountFilter.CHECKER_NAME:
if report_filter.checkerName is not None:
OR = [Report.checker_id.ilike(conv(cn))
for cn in report_filter.checkerName]
AND.append(or_(*OR))
Expand All @@ -148,18 +133,15 @@ def process_report_filter_v2(session, report_filter, count_filter=None):
if report_filter.reportHash is not None:
AND.append(Report.bug_id.in_(report_filter.reportHash))

if report_filter.severity is not None and \
count_filter != CountFilter.SEVERITY:
if report_filter.severity is not None:
AND.append(Report.severity.in_(report_filter.severity))

if report_filter.detectionStatus is not None and \
count_filter != CountFilter.DETECTION_STATUS:
if report_filter.detectionStatus is not None:
dst = list(map(detection_status_str,
report_filter.detectionStatus))
AND.append(Report.detection_status.in_(dst))

if report_filter.reviewStatus is not None and \
count_filter != CountFilter.REVIEW_STATUS:
if report_filter.reviewStatus is not None:
OR = [ReviewStatus.status.in_(
list(map(review_status_str, report_filter.reviewStatus)))]

Expand Down Expand Up @@ -193,8 +175,7 @@ def process_report_filter_v2(session, report_filter, count_filter=None):
OR.append(Report.detected_at < date)
AND.append(or_(*OR))

if report_filter.runHistoryTag is not None and \
count_filter != CountFilter.RUN_HISTORY_TAG:
if report_filter.runHistoryTag is not None:
OR = []
for history_date in report_filter.runHistoryTag:
date = datetime.strptime(history_date,
Expand All @@ -203,8 +184,7 @@ def process_report_filter_v2(session, report_filter, count_filter=None):
Report.fixed_at.is_(None), Report.fixed_at >= date)))
AND.append(or_(*OR))

if report_filter.runTag is not None and \
count_filter != CountFilter.RUN_HISTORY_TAG:
if report_filter.runTag is not None:
OR = []
for tag_id in report_filter.runTag:
history = session.query(RunHistory).get(tag_id)
Expand Down Expand Up @@ -493,7 +473,7 @@ def __get_run_ids_to_query(session, cmp_data=None):
run_ids = [r[0] for r in res]
if cmp_data:
all_rids = set(run_ids)
cmp_rids = set(cmp_data.runIds)
cmp_rids = set(cmp_data.runIds) if cmp_data.runIds else set()
run_ids = list(all_rids.difference(cmp_rids))

return run_ids
Expand Down Expand Up @@ -572,7 +552,7 @@ def getRunData(self, run_filter):

@exc_to_thrift_reqfail
@timeit
def getRunHistory(self, run_ids, limit, offset):
def getRunHistory(self, run_ids, limit, offset, run_history_filter):
self.__require_access()

with DBSession(self.__Session) as session:
Expand All @@ -582,13 +562,19 @@ def getRunHistory(self, run_ids, limit, offset):
if run_ids:
res = res.filter(RunHistory.run_id.in_(run_ids))

res = res.order_by(RunHistory.time.desc()) \
.limit(limit) \
.offset(offset)
if run_history_filter:
res = res.filter(RunHistory.version_tag.in_(
run_history_filter.tagNames))

res = res.order_by(RunHistory.time.desc())

if limit:
res = res.limit(limit).offset(offset)

results = []
for history in res:
results.append(RunHistoryData(runId=history.run.id,
results.append(RunHistoryData(id=history.id,
runId=history.run.id,
runName=history.run.name,
versionTag=history.version_tag,
user=history.user,
Expand Down Expand Up @@ -720,8 +706,7 @@ def getRunResults(self, run_ids, limit, offset, sort_types,
# There is no difference.
return results

filter_expression = process_report_filter_v2(session,
report_filter)
filter_expression = process_report_filter(session, report_filter)

path_len_q = session.query(BugPathEvent.report_id,
func.count(BugPathEvent.report_id)
Expand Down Expand Up @@ -872,8 +857,7 @@ def getRunReportCounts(self, run_ids, report_filter, limit, offset):
self.__require_access()
results = []
with DBSession(self.__Session) as session:
filter_expression = process_report_filter_v2(session,
report_filter)
filter_expression = process_report_filter(session, report_filter)

count_expr = create_count_expression(report_filter)
q = session.query(Run.id,
Expand Down Expand Up @@ -919,8 +903,7 @@ def getRunResultCount(self, run_ids, report_filter, cmp_data):
# There is no difference.
return 0

filter_expression = process_report_filter_v2(session,
report_filter)
filter_expression = process_report_filter(session, report_filter)
q = session.query(Report.bug_id)
q = filter_report_filter(q, filter_expression, run_ids, cmp_data,
diff_hashes)
Expand Down Expand Up @@ -1303,8 +1286,7 @@ def getCheckerCounts(self, run_ids, report_filter, cmp_data, limit,
# There is no difference.
return results

filter_expression = process_report_filter_v2(
session, report_filter, CountFilter.CHECKER_NAME)
filter_expression = process_report_filter(session, report_filter)

is_unique = report_filter is not None and report_filter.isUnique
if is_unique:
Expand Down Expand Up @@ -1364,9 +1346,7 @@ def getSeverityCounts(self, run_ids, report_filter, cmp_data):
# There is no difference.
return results

filter_expression = process_report_filter_v2(session,
report_filter,
CountFilter.SEVERITY)
filter_expression = process_report_filter(session, report_filter)

is_unique = report_filter is not None and report_filter.isUnique
if is_unique:
Expand Down Expand Up @@ -1412,8 +1392,7 @@ def getCheckerMsgCounts(self, run_ids, report_filter, cmp_data, limit,
# There is no difference.
return results

filter_expression = process_report_filter_v2(
session, report_filter, CountFilter.CHECKER_MSG)
filter_expression = process_report_filter(session, report_filter)

is_unique = report_filter is not None and report_filter.isUnique
if is_unique:
Expand Down Expand Up @@ -1464,8 +1443,7 @@ def getReviewStatusCounts(self, run_ids, report_filter, cmp_data):
# There is no difference.
return results

filter_expression = process_report_filter_v2(
session, report_filter, CountFilter.REVIEW_STATUS)
filter_expression = process_report_filter(session, report_filter)

is_unique = report_filter is not None and report_filter.isUnique
if is_unique:
Expand Down Expand Up @@ -1519,9 +1497,7 @@ def getFileCounts(self, run_ids, report_filter, cmp_data, limit, offset):
# There is no difference.
return results

filter_expression = process_report_filter_v2(session,
report_filter,
CountFilter.FILE)
filter_expression = process_report_filter(session, report_filter)

stmt = session.query(Report.bug_id,
Report.file_id) \
Expand Down Expand Up @@ -1576,8 +1552,7 @@ def getRunHistoryTagCounts(self, run_ids, report_filter, cmp_data):
# There is no difference.
return results

filter_expression = process_report_filter_v2(
session, report_filter, CountFilter.RUN_HISTORY_TAG)
filter_expression = process_report_filter(session, report_filter)

tag_run_ids = session.query(RunHistory.run_id.distinct()) \
.filter(RunHistory.version_tag.isnot(None)) \
Expand Down Expand Up @@ -1663,8 +1638,7 @@ def getDetectionStatusCounts(self, run_ids, report_filter, cmp_data):
# There is no difference.
return results

filter_expression = process_report_filter_v2(
session, report_filter, CountFilter.DETECTION_STATUS)
filter_expression = process_report_filter(session, report_filter)

count_expr = func.count(literal_column('*'))

Expand Down
2 changes: 1 addition & 1 deletion libcodechecker/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# The newest supported minor version (value) for each supported major version
# (key) in this particular build.
SUPPORTED_VERSIONS = {
6: 6
6: 7
}

# Used by the client to automatically identify the latest major and minor
Expand Down
Loading

0 comments on commit f0708f5

Please sign in to comment.