Skip to content

Commit

Permalink
Run history
Browse files Browse the repository at this point in the history
  • Loading branch information
csordasmarton committed Sep 14, 2017
1 parent f515099 commit 8a3b6e4
Show file tree
Hide file tree
Showing 19 changed files with 1,177 additions and 149 deletions.
45 changes: 41 additions & 4 deletions api/v6/report_server.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ struct RunFilter {
2: string name
}

struct RunHistoryData {
1: i64 runId, // Unique id of the run.
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.
}
typedef list<RunHistoryData> RunHistoryDataList

struct RunTagCount {
1: string time, // Date time of the last run.
2: string name, // Name of the tag.
3: i64 count // Count of the reports.
}
typedef list<RunTagCount> RunTagCounts

struct RunReportCount {
1: i64 runId, // unique id of the run
2: string name, // human readable name of the run
Expand Down Expand Up @@ -81,7 +97,10 @@ struct ReportFilter {
4: list<string> reportHash,
5: list<shared.Severity> severity,
6: list<shared.ReviewStatus> reviewStatus,
7: list<shared.DetectionStatus> detectionStatus
7: list<shared.DetectionStatus> detectionStatus,
8: list<string> runHistoryTag,
9: optional string firstDetectionDate,
10: optional string fixDate
}

struct ReportDetails{
Expand Down Expand Up @@ -174,6 +193,15 @@ service codeCheckerDBAccess {
RunDataList getRunData(1: RunFilter runFilter)
throws (1: shared.RequestFailed requestError),

// Get run history for runs.
// If an empty run id list is provided the history
// will be returned for all the available runs ordered by run history date.
// PERMISSION: PRODUCT_ACCESS
RunHistoryDataList getRunHistory(1: list<i64> runIds,
2: i64 limit,
3: i64 offset)
throws (1: shared.RequestFailed requestError),

// PERMISSION: PRODUCT_ACCESS
ReportData getReport(
1: i64 reportId)
Expand Down Expand Up @@ -336,6 +364,14 @@ service codeCheckerDBAccess {
3: CompareData cmpData)
throws (1: shared.RequestFailed requestError),

// 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.
// PERMISSION: PRODUCT_ACCESS
RunTagCounts getRunHistoryTagCounts(1: list<i64> runIds,
2: ReportFilter reportFilter,
3: CompareData cmpData)
throws (1: shared.RequestFailed requestError),

//============================================
// Analysis result storage related API calls.
Expand Down Expand Up @@ -364,9 +400,10 @@ service codeCheckerDBAccess {
// PERMISSION: PRODUCT_STORE
i64 massStoreRun(
1: string runName,
2: string version,
3: string zipfile,
4: bool force)
2: string tag,
3: string version,
4: string zipfile,
5: bool force)
throws (1: shared.RequestFailed requestError),

}
4 changes: 3 additions & 1 deletion docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ a database.
to the database.

~~~~~~~~~~~~~~~~~~~~~
usage: CodeChecker store [-h] [-t {plist}] [-n NAME] [-f]
usage: CodeChecker store [-h] [-t {plist}] [-n NAME] [--tag TAG] [-f]
[--url PRODUCT_URL]
[--verbose {info,debug,debug_analyzer}]
[file/folder [file/folder ...]]
Expand All @@ -693,6 +693,8 @@ optional arguments:
reports to the database. If not specified, the '--
name' parameter given to 'codechecker-analyze' will be
used, if exists.
--tag TAG A unique identifier for this individual store of results
in the run's history.
-f, --force Delete analysis results stored in the database for the
current analysis run's name and store only the results
reported in the 'input' files. (By default,
Expand Down
30 changes: 25 additions & 5 deletions libcodechecker/analyze/store_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def is_same_event_path(report_id, events, session):
str(ex))


def addCheckerRun(session, storage_session, command, name, version, force):
def addCheckerRun(session, storage_session, command, name, tag, username,
run_history_time, version, force):
"""
Store checker run related data to the database.
By default updates the results if name already exists.
Expand Down Expand Up @@ -246,6 +247,22 @@ def addCheckerRun(session, storage_session, command, name, version, force):
session.flush()
run_id = checker_run.id

# Add run to the history.
LOG.debug("adding run to the history")

if tag is not None:
version_tag = session.query(RunHistory) \
.filter(RunHistory.run_id == run_id,
RunHistory.version_tag == tag) \
.one_or_none()

if version_tag:
raise Exception('Tag ' + tag + ' is already used in this run')

run_history = RunHistory(run_id, tag, username, run_history_time)
session.add(run_history)
session.flush()

storage_session.start_run_session(run_id, session)
return run_id
except Exception as ex:
Expand All @@ -255,7 +272,7 @@ def addCheckerRun(session, storage_session, command, name, version, force):
str(ex))


def finishCheckerRun(storage_session, run_id):
def finishCheckerRun(storage_session, run_id, run_history_time):
"""
"""
try:
Expand All @@ -269,7 +286,7 @@ def finishCheckerRun(storage_session, run_id):

run.mark_finished()

storage_session.end_run_session(run_id)
storage_session.end_run_session(run_id, run_history_time)

return True

Expand Down Expand Up @@ -303,7 +320,8 @@ def addReport(storage_session,
bugpath,
events,
checker_id,
severity):
severity,
detection_time):
"""
"""
try:
Expand Down Expand Up @@ -346,6 +364,7 @@ def addReport(storage_session,
elif report.detection_status == 'resolved':
new_status = 'reopened'
report.file_id = file_id
report.fixed_at = None
change_path_and_events(session,
report.id,
bugpath,
Expand All @@ -369,7 +388,8 @@ def addReport(storage_session,
line_num,
column,
severity,
"new")
"new",
detection_time)

session.add(report)
session.flush()
Expand Down
2 changes: 1 addition & 1 deletion libcodechecker/libclient/thrift_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,5 @@ def getMissingContentHashes(self, file_hashes):
pass

@ThriftClientCall
def massStoreRun(self, name, version, zipdir, force):
def massStoreRun(self, name, tag, version, zipdir, force):
pass
9 changes: 9 additions & 0 deletions libcodechecker/libhandlers/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def add_arguments_to_parser(parser):
"the '--name' parameter given to 'codechecker-"
"analyze' will be used, if exists.")

parser.add_argument('--tag',
type=str,
dest="tag",
required=False,
default=argparse.SUPPRESS,
help="A uniques identifier for this individual store "
"of results in the run's history.")

parser.add_argument('-f', '--force',
dest="force",
default=argparse.SUPPRESS,
Expand Down Expand Up @@ -334,6 +342,7 @@ def main(args):
context = generic_package_context.get_context()

client.massStoreRun(args.name,
args.tag if 'tag' in args else None,
context.version,
b64zip,
'force' in args)
Expand Down
Loading

0 comments on commit 8a3b6e4

Please sign in to comment.