Skip to content

Commit

Permalink
Added sorting based on cluster.
Browse files Browse the repository at this point in the history
  • Loading branch information
kajdreef committed Nov 8, 2020
1 parent 1a9e6c9 commit 836a010
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
25 changes: 25 additions & 0 deletions src/components/filters/sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,31 @@ export function sort_by_coverage_Y(current_state, all_data) {
}
}


export function sort_by_cluster_X(current_state, all_data) {
let x = current_state.x;
const y = current_state.y;
const edges = current_state.edges;

return {
x: x.sort((e1, e2) => e1.get_cluster() < e2.get_cluster()),
y: y,
edges: edges,
}
}

export function sort_by_cluster_Y(current_state, all_data) {
const x = current_state.x;
let y = current_state.y;
const edges = current_state.edges;

return {
x: x,
y: y.sort((e1, e2) => e1.get_cluster() < e2.get_cluster()),
edges: edges,
}
}

export function sort_by_suspciousness(current_state, all_data) {
let x = current_state.x;
let y = current_state.y;
Expand Down
15 changes: 10 additions & 5 deletions src/components/routes/TestMatrixView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import './TestMatrixView.scss';
import { filter_by_num_method_covered, filter_by_test_passed, filter_by_coexecuted_tests, filter_by_test_type, TEST_TYPES, TEST_RESULT} from '../filters/test_filters';
import { filter_method_by_number_of_times_tested, filter_by_coexecuted_methods } from '../filters/method_filters';
import { process_data, FunctionMap } from '../filters/data_processor';
import { sort_by_coverage_X, sort_by_coverage_Y, sort_by_suspciousness} from '../filters/sorting';
import { sort_by_cluster_X, sort_by_cluster_Y, sort_by_coverage_X, sort_by_coverage_Y, sort_by_suspciousness} from '../filters/sorting';

class TestMatrixView extends Component {
constructor(props) {
Expand Down Expand Up @@ -101,18 +101,19 @@ class TestMatrixView extends Component {
console.debug(`${API_ROOT}/coverage/${project_name}/${commit_sha}`);
return await json(`${API_ROOT}/coverage/${project_name}/${commit_sha}`)
.then((response) => {
console.log("Response: ", response);
return {
methods: response.coverage.methods.map(m => {
m.get_id = () => m.method_id;
m.to_string = () => `${m.package_name}.${m.class_name} ${m.method_decl}`;
m.get_group = () => m.hasOwnProperty('cluster_id') ? m.cluster_id : 0;
m.get_cluster = () => m.hasOwnProperty('cluster_id') ? m.cluster_id : 0;
m.get_color = () => m.package_name
return m;
}),
tests: response.coverage.tests.map(t => {
t.get_id = () => t.test_id;
t.to_string = () => `${t.class_name} ${t.method_name}`;
t.get_group = () => t.hasOwnProperty('cluster_id') ? t.cluster_id : 0;
t.get_cluster = () => t.hasOwnProperty('cluster_id') ? t.cluster_id : 0;
t.get_color = () => t.class_name
return t;
}),
Expand Down Expand Up @@ -250,6 +251,7 @@ class TestMatrixView extends Component {
func = sort_by_coverage_X;
break
case "Cluster":
func = sort_by_cluster_X;
break;
case "Suspiciousness":
func = sort_by_suspciousness;
Expand All @@ -266,7 +268,8 @@ class TestMatrixView extends Component {
entries={[
{ key: 0, value: "Name" },
{ key: 1, value: "Coverage" },
{ key: 2, value: "Suspiciousness"}
{ key: 2, value: "Cluster" },
{ key: 3, value: "Suspiciousness"}
]} />
<Menu
title="Sort Y-Axis"
Expand All @@ -278,6 +281,7 @@ class TestMatrixView extends Component {
func = sort_by_coverage_Y;
break
case "Cluster":
func = sort_by_cluster_Y;
break;
default:
break;
Expand All @@ -290,7 +294,8 @@ class TestMatrixView extends Component {
}}
entries={[
{ key: 0, value: "Name" },
{ key: 1, value: "Coverage" }
{ key: 1, value: "Coverage" },
{ key: 2, value: "Cluster" },
]} />
</AccordionDetails>
</Accordion>
Expand Down

0 comments on commit 836a010

Please sign in to comment.