Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/showing-closed-reports' into sho…
Browse files Browse the repository at this point in the history
…wing-closed-reports
  • Loading branch information
cservakt committed May 14, 2024
2 parents 7bb4679 + b5c56d9 commit 837fdf2
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 23 deletions.
Binary file modified web/api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz
Binary file not shown.
Binary file modified web/api/py/codechecker_api/dist/codechecker_api.tar.gz
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion web/api/report_server.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ struct ReportFilter {
// [(key1, value1), (key1, value2), (key2, value3)] returns reports which
// have "value1" OR "value2" for "key1" AND have "value3" for "key2".
22: optional list<Pair> annotations,
23: optinal list<ReportStatus> reportStatus, // Specifying the status of the filtered reports.
23: list<ReportStatus> reportStatus, // Specifying the status of the filtered reports.
}

struct RunReportCount {
Expand Down
75 changes: 68 additions & 7 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
DetectionStatus, DiffType, \
Encoding, ExportData, \
Order, \
ReportData, ReportDetails, ReviewData, ReviewStatusRule, \
ReportData, ReportDetails, ReportStatus, ReviewData, ReviewStatusRule, \
ReviewStatusRuleFilter, ReviewStatusRuleSortMode, \
ReviewStatusRuleSortType, RunData, RunFilter, RunHistoryData, \
RunReportCount, RunSortType, RunTagCount, \
Expand Down Expand Up @@ -70,8 +70,8 @@
SourceComponent

from .thrift_enum_helper import detection_status_enum, \
detection_status_str, review_status_enum, review_status_str, \
report_extended_data_type_enum
detection_status_str, report_status_enum, report_status_str, \
review_status_enum, review_status_str, report_extended_data_type_enum


LOG = get_logger('server')
Expand Down Expand Up @@ -302,21 +302,23 @@ def process_report_filter(
AND.append(or_(*OR))

if report_filter.reportStatus:
print("itt")
# DetectionStatus.NEW DetectionStatus.RESOLVED DetectionStatus.UNRESOLVED DetectionStatus.REOPENED DetectionStatus.OFF DetectionStatus.UNAVAILABLE:
# ReviewStatus.UNREVIEWED ReviewStatus.CONFIRMED ReviewStatus.FALSE_POSITIVE ReviewStatus.INTENTIONAL:
dst = list(map(detection_status_str,
(DetectionStatus.NEW,
(DetectionStatus.NEW,
DetectionStatus.UNRESOLVED,
DetectionStatus.REOPENED)))
rst = list(map(review_status_str,
(ReviewStatus.UNREVIEWED,
(ReviewStatus.UNREVIEWED,
ReviewStatus.CONFIRMED)))

if report_filter.reportStatus.isOutstanding:
if ReportStatus.OUTSTANDING in report_filter.reportStatus:
AND.append(and_(Report.review_status.in_(rst), Report.detection_status.in_(dst)))

if report_filter.reportStatus.isClosed:
if ReportStatus.CLOSED in report_filter.reportStatus:
AND.append(not_(and_(Report.review_status.in_(rst), Report.detection_status.in_(dst))))
print("teszt")
print(*AND)

if report_filter.detectionStatus and not report_filter.reportStatus:
Expand Down Expand Up @@ -1885,6 +1887,9 @@ def getDiffResultsHash(self, run_ids, report_hashes, diff_type,
@timeit
def getRunResults(self, run_ids, limit, offset, sort_types,
report_filter, cmp_data, get_details):
if report_filter.detectionStatus:
print("report_filter")
print(report_filter.detectionStatus)
self.__require_view()

limit = verify_limit_range(limit)
Expand Down Expand Up @@ -3273,6 +3278,62 @@ def getCheckerMsgCounts(self, run_ids, report_filter, cmp_data, limit,
results = dict(checker_messages.all())
return results

@exc_to_thrift_reqfail
@timeit
def getReportStatusCounts(self, run_ids, report_filter, cmp_data):
"""
If the run id list is empty the metrics will be counted
for all of the runs and in compare mode all of the runs
will be used as a baseline excluding the runs in compare data.
"""
self.__require_view()
with DBSession(self._Session) as session:
filter_expression, join_tables = process_report_filter(
session, run_ids, report_filter, cmp_data)

extended_table = session.query(
Report.review_status,
Report.detection_status,
Report.bug_id
)

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 = apply_report_filter(
extended_table, filter_expression, join_tables)

extended_table = extended_table.subquery()

is_opened_case = get_is_opened_case(extended_table)


if report_filter.isUnique:
q = session.query(
is_opened_case.label("isOpened"),
func.count(extended_table.c.bug_id.distinct())) \
.group_by(is_opened_case)
else:
q = session.query(
is_opened_case.label("isOpened"),
func.count(extended_table.c.bug_id)) \
.group_by(is_opened_case)

# return {ReportStatus.OUTSTANDING if isOutstanding
# else ReportStatus.CLOSED: count
# for isOutstanding, count in q}
results = {
report_status_enum("outstanding" if isOutstanding
else "closed"): count
for isOutstanding, count in q}
print("results")
print(results)
return results


@exc_to_thrift_reqfail
@timeit
def getReviewStatusCounts(self, run_ids, report_filter, cmp_data):
Expand Down
20 changes: 19 additions & 1 deletion web/server/codechecker_server/api/thrift_enum_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


from codechecker_api.codeCheckerDBAccess_v6.ttypes import DetectionStatus, \
ExtendedReportDataType, ReviewStatus
ExtendedReportDataType, ReportStatus, ReviewStatus
from codechecker_api.ProductManagement_v6.ttypes import Confidentiality


Expand Down Expand Up @@ -119,3 +119,21 @@ def report_extended_data_type_enum(status):
return ExtendedReportDataType.MACRO
elif status == 'fixit':
return ExtendedReportDataType.FIXIT

def report_status_str(status):
"""
Returns the given report status Thrift enum value.
"""
if status == ReportStatus.OUTSTANDING:
return 'outstanding'
elif status == ReportStatus.CLOSED:
return 'closed'

def report_status_enum(status):
"""
Converts the given report status to string.
"""
if status == 'outstanding':
return ReportStatus.OUTSTANDING
elif status == 'closed':
return ReportStatus.CLOSED
36 changes: 36 additions & 0 deletions web/server/vue-cli/src/components/Icons/ReportStatusIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<v-icon
v-if="status === ReportStatus.OUTSTANDING"
color="error"
title="Outstanding"
:size="size"
>
mdi-alert
</v-icon>

<v-icon
v-else-if="status === ReportStatus.CLOSED"
color="primary"
title="Closed"
:size="size"
>
mdi-close
</v-icon>
</template>

<script>
import { ReportStatus } from "@cc/report-server-types";
export default {
name: "ReportStatusIcon",
props: {
status: { type: Number, required: true },
size: { type: Number, default: null }
},
data() {
return {
ReportStatus
};
}
};
</script>
2 changes: 2 additions & 0 deletions web/server/vue-cli/src/components/Icons/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AnalyzerStatisticsIcon from "./AnalyzerStatisticsIcon";
import ConfidentialityIcon from "./ConfidentialityIcon";
import DetectionStatusIcon from "./DetectionStatusIcon";
import ReportStatusIcon from "./ReportStatusIcon";
import ReportStepEnumIcon from "./ReportStepEnumIcon";
import ReviewStatusIcon from "./ReviewStatusIcon";
import SeverityIcon from "./SeverityIcon";
Expand All @@ -10,6 +11,7 @@ export {
AnalyzerStatisticsIcon,
ConfidentialityIcon,
DetectionStatusIcon,
ReportStatusIcon,
ReportStepEnumIcon,
ReviewStatusIcon,
SeverityIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@input="setSelectedItems"
>
<template v-slot:icon="{ item }">
<review-status-icon :status="item.id" />
<report-status-icon :status="item.id" />
</template>

<template v-slot:append-toolbar-title>
Expand Down Expand Up @@ -47,10 +47,10 @@
<script>
import { ccService, handleThriftError } from "@cc-api";
import { ReportFilter, ReviewStatus } from "@cc/report-server-types";
import { ReportFilter, ReportStatus } from "@cc/report-server-types";
import TooltipHelpIcon from "@/components/TooltipHelpIcon";
import { ReviewStatusIcon } from "@/components/Icons";
import { ReviewStatusMixin } from "@/mixins";
import { ReportStatusIcon } from "@/components/Icons";
import { ReportStatusMixin } from "@/mixins";
import { SelectOption, SelectedToolbarTitleItems } from "./SelectOption";
import BaseSelectOptionFilterMixin from "./BaseSelectOptionFilter.mixin";
Expand All @@ -59,11 +59,11 @@ export default {
name: "ReportStatusFilter",
components: {
SelectOption,
ReviewStatusIcon,
ReportStatusIcon,
SelectedToolbarTitleItems,
TooltipHelpIcon
},
mixins: [ BaseSelectOptionFilterMixin, ReviewStatusMixin ],
mixins: [ BaseSelectOptionFilterMixin, ReportStatusMixin ],
data() {
return {
Expand All @@ -72,12 +72,12 @@ export default {
},
methods: {
encodeValue(reviewStatusId) {
return this.reviewStatusFromCodeToString(reviewStatusId);
encodeValue(reportStatusId) {
return this.reportStatusFromCodeToString(reportStatusId);
},
decodeValue(reviewStatusName) {
return this.reviewStatusFromStringToCode(reviewStatusName);
decodeValue(reportStatusName) {
return this.reportStatusFromStringToCode(reportStatusName);
},
updateReportFilter() {
Expand All @@ -95,13 +95,13 @@ export default {
this.loading = true;
const reportFilter = new ReportFilter(this.reportFilter);
reportFilter.reviewStatus = null;
reportFilter.reportStatus = null;
return new Promise(resolve => {
ccService.getClient().getReviewStatusCounts(this.runIds, reportFilter,
ccService.getClient().getReportStatusCounts(this.runIds, reportFilter,
this.cmpData, handleThriftError(res => {
resolve(Object.keys(ReviewStatus).map(status => {
const id = ReviewStatus[status];
resolve(Object.keys(ReportStatus).map(status => {
const id = ReportStatus[status];
return {
id: id,
title: this.encodeValue(id),
Expand Down
2 changes: 2 additions & 0 deletions web/server/vue-cli/src/mixins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import BugPathLengthColorMixin from "./bug-path-length-color.mixin";
import ConfidentialityMixin from "./confidentiality.mixin";
import DateMixin from "./date.mixin";
import DetectionStatusMixin from "./detection-status.mixin";
import ReportStatusMixin from "./report-status.mixin";
import ReviewStatusMixin from "./review-status.mixin";
import SeverityMixin from "./severity.mixin";
import StrToColorMixin from "./str-to-color.mixin";
Expand All @@ -13,6 +14,7 @@ export {
ConfidentialityMixin,
DateMixin,
DetectionStatusMixin,
ReportStatusMixin,
ReviewStatusMixin,
SeverityMixin,
StrToColorMixin,
Expand Down
27 changes: 27 additions & 0 deletions web/server/vue-cli/src/mixins/report-status.mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ReportStatus } from "@cc/report-server-types";

export default {
methods: {
reportStatusFromCodeToString(reportCode) {
switch (reportCode) {
case ReportStatus.OUTSTANDING:
return "Outstanding";
case ReportStatus.CLOSED:
return "Closed";
default:
return "";
}
},

reportStatusFromStringToCode(status) {
switch (status.toLowerCase()) {
case "outstanding":
return ReportStatus.OUTSTANDING;
case "closed":
return ReportStatus.CLOSED;
default:
return -1;
}
}
}
};
1 change: 1 addition & 0 deletions web/server/vue-cli/src/views/Reports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export default {
const offset = limit * (this.pagination.page - 1);
const sortType = this.getSortMode();
const getDetails = false;
this.reportFilter.detectionStatus = [ 1 ];
ccService.getClient().getRunResults(this.runIds, limit, offset, sortType,
this.reportFilter, this.cmpData, getDetails,
Expand Down

0 comments on commit 837fdf2

Please sign in to comment.