Skip to content

Commit

Permalink
Merge pull request #387 from MetaCell/fix-suites_score
Browse files Browse the repository at this point in the history
Fix suites score
  • Loading branch information
ddelpiano committed Aug 30, 2019
2 parents efff809 + 93cc537 commit e6844b1
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 57 deletions.
4 changes: 2 additions & 2 deletions actions/creators/test-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export function filteringSuitesStarted (searchText, filterName, dispatch){
apiService.getList(false, Config.suiteNamespace).then(result => {

let filters = filteringService.getFilters(Config.suiteNamespace);
let filterString = Object.keys(filters).length ? "/?" + filteringService.stringifyFilters(filters) : "";
let filterString = Object.keys(filters).length ? "?" + filteringService.stringifyFilters(filters) : "";

window.history.pushState("", "", filterString);
window.history.pushState("", "", `${location.pathname}` + filterString);
dispatch(filteringSuitesFinished(result));

});
Expand Down
5 changes: 4 additions & 1 deletion actions/test-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ export function filteringSuitesStarted (state, action) {
export function filteringSuitesFinished (state, action) {

let adapter = new TestSuitesGriddleAdapter(action.scores);
let scoreMatrixAdapter = new ScoreMatrixGriddleAdapter(action.scores);

$(".griddle-page-select").show();

let newState = {
...state,
data: adapter.getGriddleData()
data: adapter.getGriddleData(),
scoreMatrixTableDataList: scoreMatrixAdapter.getGriddleData(),
scoreMatrixList: scoreMatrixAdapter.getScoreMatrix()
};

return newState;
Expand Down
6 changes: 2 additions & 4 deletions components/models/Models.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ export default class Models extends React.Component {
}

componentWillUpdate (nextProps, nextState) {
if(this.props.data.length !== nextProps.data.length) {
this.griddleData = [];
for ( var i = 0; i < nextProps.data.length; i++) {
this.griddleData = [];
for ( var i = 0; i < nextProps.data.length; i++) {
let griddleItem = _.clone(nextProps.data[i]);
let newItem = _.clone(nextProps.data[i]);
griddleItem.nameLink = nextProps.data[i].name;
Expand All @@ -60,7 +59,6 @@ export default class Models extends React.Component {
newItem.name = griddleItem;
this.griddleData.push(newItem);
}
}
}

render (){
Expand Down
40 changes: 22 additions & 18 deletions shared/adapter/ScoreMatrixGriddleAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default class ScoreMatrixGriddleAdapter extends BaseAdapter {
let suiteHashes = new Set();

for (let score of this.getRawData()) {
suiteHashes.add(score.test_instance.test_suites[0].hash);
for (let suite of score.test_instance.test_suites){
suiteHashes.add(suite.hash);
}
}

for (let hash of suiteHashes) {
Expand All @@ -47,27 +49,29 @@ export default class ScoreMatrixGriddleAdapter extends BaseAdapter {
]
};
for (let score of this.getRawData()) {
if (hash != score.test_instance.test_suites[0].hash) {
continue;
}
for (let suite of score.test_instance.test_suites){
if (hash != suite.hash) {
continue;
}

let modelInstanceName = score.model_instance.name;
let modelInstanceId = score.model_instance.id;
let testHashId = score.test_instance.hash_id;
let modelKey = `${modelInstanceName}_${modelInstanceId}`;
let modelInstanceName = score.model_instance.name;
let modelInstanceId = score.model_instance.id;
let testHashId = score.test_instance.hash_id;
let modelKey = `${modelInstanceName}_${modelInstanceId}`;

if (this.hiddenModels.includes(modelKey)) {
continue;
}
if (this.hiddenModels.includes(modelKey)) {
continue;
}

if (!(modelKey in scoreMatrix.rows)) {
scoreMatrix.rows[modelKey] = {
title: modelInstanceName,
info: new Map()
};
}
if (!(modelKey in scoreMatrix.rows)) {
scoreMatrix.rows[modelKey] = {
title: modelInstanceName,
info: new Map()
};
}

scoreMatrix.rows[modelKey]["info"].set(testHashId, score);
scoreMatrix.rows[modelKey]["info"].set(testHashId, score);
}
}

let biggestRow = new Map();
Expand Down
90 changes: 58 additions & 32 deletions shared/adapter/TestSuitesGriddleAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,66 @@ export default class TestSuitesGriddleAdapter extends BaseAdapter {
};

for (let score of this.getRawData()) {
let suiteHash = score.test_instance.test_suites[0].hash;
let suiteObject = score.test_instance.test_suites[0];
let suiteTimestamp = score.test_instance.test_suites[0].timestamp;
let modelInstanceName = score.model_instance.name;
let modelSuiteKey = suiteHash + "_" + modelInstanceName;

if (!(modelSuiteKey in result)) {
result[modelSuiteKey] = {};
}

result[modelSuiteKey]["suite"] = suiteHash;
result[modelSuiteKey]["suiteObject"] = suiteObject;
result[modelSuiteKey]["model"] = score.model_instance;

if (!("avgScore" in result[modelSuiteKey])) {
result[modelSuiteKey]["avgScore"] = {
value: null,
scoreList: []
for (let suite of score.test_instance.test_suites) {
let suiteHash = suite.hash;
let suiteTimestamp = suite.timestamp;
let modelSuiteKey = suiteHash + "_" + score.model_instance.hash_id;

if (!(modelSuiteKey in result)) {
result[modelSuiteKey] = {};
}

result[modelSuiteKey]["suite"] = suiteHash;
result[modelSuiteKey]["suiteObject"] = suite;
result[modelSuiteKey]["model"] = score.model_instance;

if (!("avgScore" in result[modelSuiteKey])) {
result[modelSuiteKey]["avgScore"] = {
value: null,
scoreList: []
};
}

if ((suiteHash + "_" + score.model_instance.hash_id) == modelSuiteKey){
let usedTest = false;

for (let usedScore of result[modelSuiteKey]["avgScore"]["scoreList"] )
{
if (usedScore.test_instance.hash_id == score.test_instance.hash_id){
usedTest = true;
}
}

if (!usedTest){
result[modelSuiteKey]["avgScore"]["scoreList"].push(score);
}
}

let tests = [];
for (let score of result[modelSuiteKey]["avgScore"]["scoreList"]) {
if (!tests.includes(score.test_instance.hash_id)) {
tests.push(score.test_instance.hash_id);
}
}

result[modelSuiteKey]["testsCount"] = tests.length;

let fullDate = new Date(suiteTimestamp).toLocaleString(
"en-US",
options
);
let shortDate = new Date(suiteTimestamp).toLocaleString("en-US", {
year: "numeric",
month: "long",
day: "numeric"
});

result[modelSuiteKey]["timestamp"] = {
full: fullDate,
short: shortDate
};
result[modelSuiteKey]["_timestamp"] = suiteTimestamp;
}

result[modelSuiteKey]["avgScore"]["scoreList"].push(score);
result[modelSuiteKey]["testsCount"] =
result[modelSuiteKey]["avgScore"]["scoreList"].length;

let fullDate = new Date(suiteTimestamp).toLocaleString("en-US", options);
let shortDate = new Date(suiteTimestamp).toLocaleString("en-US", {
year: "numeric",
month: "long",
day: "numeric"
});

result[modelSuiteKey]["timestamp"] = { full: fullDate, short: shortDate };
result[modelSuiteKey]["_timestamp"] = suiteTimestamp;
}

let list = Object.values(result);
Expand Down

0 comments on commit e6844b1

Please sign in to comment.