8000 Search for run names. by csordasmarton · Pull Request #753 · Ericsson/codechecker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Search for run names. #753

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

Merged
merged 1 commit into from
Jul 31, 2017
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
2 changes: 1 addition & 1 deletion api/report_server.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ typedef list<CommentData> CommentDataList
service codeCheckerDBAccess {

// get the run Ids and dates from the database to select one run
RunDataList getRunData()
RunDataList getRunData(1: string runNameFilter)
throws (1: shared.RequestFailed requestError),

ReportData getReport(
Expand Down
4 changes: 2 additions & 2 deletions libcodechecker/cmd/cmd_line_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_run_ids(client):
Returns a map for run names and run_ids.
"""

runs = client.getRunData()
runs = client.getRunData(None)

run_data = {}
for run in runs:
Expand Down Expand Up @@ -112,7 +112,7 @@ def add_filter_conditions(report_filter, filter_str):

def handle_list_runs(args):
client = setup_client(args.host, args.port, '/')
runs = client.getRunData()
runs = client.getRunData(None)

if args.output_format == 'json':
results = []
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 @@ -73,7 +73,7 @@ def wrapper(self, *args, **kwargs):
return wrapper

@ThriftClientCall
def getRunData(self):
def getRunData(self, runNameFilter):
pass

@ThriftClientCall
Expand Down
10 changes: 7 additions & 3 deletions libcodechecker/server/client_db_access_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def __queryResults(self, run_id, limit, offset, sort_types,
msg)

@timeit
def getRunData(self):
def getRunData(self, run_name_filter):

session = self.__session
results = []
Expand All @@ -273,8 +273,12 @@ def getRunData(self):
.group_by(Report.run_id) \
.subquery()

q = session.query(Run, stmt.c.report_count) \
.outerjoin(stmt, Run.id == stmt.c.run_id) \
q = session.query(Run, stmt.c.report_count)

if run_name_filter is not None:
q = q.filter(Run.name.like('%' + run_name_filter + '%'))

q = q.outerjoin(stmt, Run.id == stmt.c.run_id) \
.order_by(Run.date)

for instance, reportCount in q:
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/comment/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setUp(self):
# Get the run names which belong to this test
run_names = env.get_run_names(self._test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]

Expand Down
10 changes: 5 additions & 5 deletions tests/functional/delete_runs/test_delete_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def test_multiple_deletion(self):
"""

def all_exists(runs):
run_names = [run.name for run in self._cc_client.getRunData()]
run_names = [run.name for run in self._cc_client.getRunData(None)]
print(run_names)
return set(runs) <= set(run_names)

def none_exists(runs):
run_names = [run.name for run in self._cc_client.getRunData()]
run_names = [run.name for run in self._cc_client.getRunData(None)]
return not bool(set(runs).intersection(run_names))

project_name = self._testproject_data['name']
Expand All @@ -89,9 +89,9 @@ def none_exists(runs):

# Remove runs before run 2 by run date.

run2 = next(itertools.ifilter(
lambda run: run.name == run2_name, self._cc_client.getRunData()),
None)
run2 = next(itertools.ifilter(lambda run: run.name == run2_name,
self._cc_client.getRunData(None)), None)

date_run2 = datetime.strptime(run2.runDate, '%Y-%m-%d %H:%M:%S.%f')
date_run2 = \
str(date_run2.year) + ':' + \
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/diff/test_regression_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def setUp(self):
# Get the run names which belong to this test.
run_names = env.get_run_names(test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]
for r in test_runs:
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/func_template/template_test.py
F438
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def setUp(self):
# Get the run names which belong to this test.
run_names = env.get_run_names(test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)
test_runs = [run for run in runs if run.name in run_names]

def test_skel(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/report_viewer_api/test_get_run_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setUp(self):
# Get the run names which belong to this test.
run_names = env.get_run_names(test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/report_viewer_api/test_report_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):
# Get the run names which belong to this test.
run_names = env.get_run_names(test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]

Expand Down
57 changes: 57 additions & 0 deletions tests/functional/report_viewer_api/test_run_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# -----------------------------------------------------------------------------
# The CodeChecker Infrastructure
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
# -----------------------------------------------------------------------------

import os
import unittest

from libtest import env


class TestRunFilter(unittest.TestCase):

_ccClient = None

def setUp(self):
test_workspace = os.environ['TEST_WORKSPACE']

test_class = self.__class__.__name__
print('Running ' + test_class + ' tests in ' + test_workspace)

self._testproject_data = env.setup_test_proj_cfg(test_workspace)
self.assertIsNotNone(self._testproject_data)

self._cc_client = env.setup_viewer_client(test_workspace)
self.assertIsNotNone(self._cc_client)

self._run_names = env.get_run_names(test_workspace)

def __get_runs(self, run_name_filter=None):
""" Helper function to get all run names which belong to this test"""
runs = self._cc_client.getRunData(run_name_filter)

return [run for run in runs if run.name in self._run_names]

def test_filter_run_names(self):
# Filter all runs.
test_runs = self.__get_runs()
self.assertEqual(len(test_runs), 1,
"There should be only one run for this test.")

# Filter runs which name starts with `test_files_`.
test_runs = self.__get_runs('test_files_')
self.assertEqual(len(test_runs), 1,
"There should be only one run for this test.")

# Filter runs which name contains `files`.
test_runs = self.__get_runs('files_')
self.assertEqual(len(test_runs), 1,
"There should be no run for this test.")

# Filter non existing run.
test_runs = self.__get_runs('non_existing_run_name')
self.assertEqual(len(test_runs), 0,
"There should be no run for this test.")
2 changes: 1 addition & 1 deletion tests/functional/skip/test_skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def setUp(self):
# Get the run names which belong to this test.
run_names = env.get_run_names(test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/suppress/test_suppress.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def setUp(self):
# Get the run names which belong to this test.
run_names = env.get_run_names(test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/suppress/test_suppress_file_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setUp(self):
# Get the run names which belong to this test.
run_names = env.get_run_names(test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/update/test_update_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUp(self):
# Get the run names which belong to this test
run_names = env.get_run_names(self._test_workspace)

runs = self._cc_client.getRunData()
runs = self._cc_client.getRunData(None)

test_runs = [run for run in runs if run.name in run_names]

Expand Down
2 changes: 1 addition & 1 deletion tests/performance/run_performance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def measure(test_conf,
with CCViewerHelper(view_host, view_port, '/') as viewer_client:

with Timer('getRunData', run_perf):
viewer_client.getRunData()
viewer_client.getRunData(None)

with Timer('getAllRunResulst', run_perf):
res = get_all_run_results(viewer_client, run_id)
Expand Down
106 changes: 87 additions & 19 deletions www/scripts/codecheckerviewer/ListOfRuns.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ define([
'dojo/topic',
'dijit/Dialog',
'dijit/form/Button',
'dijit/form/TextBox',
'dijit/layout/BorderContainer',
'dijit/layout/ContentPane',
'dojox/grid/DataGrid'],
function (declare, domConstruct, ItemFileWriteStore, topic, Dialog, Button,
BorderContainer, ContentPane, DataGrid) {
TextBox, BorderContainer, ContentPane, DataGrid) {

function prettifyDuration(seconds) {
var prettyDuration = "--------";
Expand Down Expand Up @@ -137,33 +138,70 @@ function (declare, domConstruct, ItemFileWriteStore, topic, Dialog, Button,
return result;
},

_populateRuns : function () {
/**
* Sorts run data list by date (newest comes first).
*/
_sortRunData : function (runDataList) {
runDataList.sort(function (lhs, rhs) {
return new Date(rhs.runDate) - new Date(lhs.runDate);
});
},

/**
* This function refreshes grid with available run data based on text run
* name filter.
*/
refreshGrid : function (runNameFilter) {
var that = this;

CC_SERVICE.getRunData(function (runDataList) {
runDataList.sort(function (lhs, rhs) {
return new Date(rhs.runDate) - new Date(lhs.runDate);
this.store.fetch({
onComplete : function (runs) {
runs.forEach(function (run) {
that.store.deleteItem(run);
});
that.store.save();
}
});

CC_SERVICE.getRunData(runNameFilter, function (runDataList) {
that._sortRunData(runDataList);
runDataList.forEach(function (item) {
that._addRunData(item);
});
});
},

/**
* This function adds a new run data to the store.
*/
_addRunData : function (runData) {
var currItemDate = runData.runDate.split(/[\s\.]+/);
this.store.newItem({
id : runData.runId,
runid : runData.runId,
name : '<span class="link">' + runData.name + '</span>',
date : currItemDate[0] + ' ' + currItemDate[1],
numberofbugs : runData.resultCount,
duration : prettifyDuration(runData.duration),
runData : runData,
checkcmd : '<span class="link">Show</span>',
del : false,
diff : false
});
},

_populateRuns : function (runNameFilter) {
var that = this;

CC_SERVICE.getRunData(runNameFilter, function (runDataList) {
that._sortRunData(runDataList);

that.onLoaded(runDataList);
topic.publish("hooks/RunsListed", runDataList.length);

runDataList.forEach(function (item) {
var currItemDate = item.runDate.split(/[\s\.]+/);
topic.publish("hooks/run/Observed", item);

that.store.newItem({
diff : false,
id : item.runId,
runid : item.runId,
name : '<span class="link">' + item.name + '</span>',
date : currItemDate[0] + ' ' + currItemDate[1],
numberofbugs : item.resultCount,
duration : prettifyDuration(item.duration),
del : false,
runData : item,
checkcmd : '<span class="link">Show</span>'
});
that._addRunData(item);
});
});
},
Expand Down Expand Up @@ -285,10 +323,38 @@ function (declare, domConstruct, ItemFileWriteStore, topic, Dialog, Button,
}
});

var RunFilter = declare(ContentPane, {
constructor : function () {
var that = this;

this._runFilter = new TextBox({
id : 'runs-filter',
placeHolder : 'Search for runs...',
onKeyUp : function (evt) {
clearTimeout(this.timer);

var filter = this.get('value');
this.timer = setTimeout(function () {
that.listOfRunsGrid.refreshGrid(filter);
}, 500);
}
});
},

postCreate : function () {
this.addChild(this._runFilter);
}
});

return declare(BorderContainer, {
postCreate : function () {
var that = this;

var filterPane = new RunFilter({
id : 'runs-filter-container',
region : 'top'
});

var runsInfoPane = new RunsInfoPane({
region : 'bottom'
});
Expand All @@ -300,7 +366,9 @@ function (declare, domConstruct, ItemFileWriteStore, topic, Dialog, Button,
});

runsInfoPane.set('listOfRunsGrid', listOfRunsGrid);
filterPane.set('listOfRunsGrid', listOfRunsGrid);

this.addChild(filterPane);
this.addChild(runsInfoPane);
this.addChild(listOfRunsGrid);
},
Expand Down
0