diff --git a/actions/creators/test-suites.js b/actions/creators/test-suites.js index e100f16..222f8fc 100644 --- a/actions/creators/test-suites.js +++ b/actions/creators/test-suites.js @@ -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)); }); diff --git a/actions/test-suites.js b/actions/test-suites.js index 9824164..e9c567a 100644 --- a/actions/test-suites.js +++ b/actions/test-suites.js @@ -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; diff --git a/components/models/Models.js b/components/models/Models.js index 5b880a4..5aca358 100644 --- a/components/models/Models.js +++ b/components/models/Models.js @@ -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; @@ -60,7 +59,6 @@ export default class Models extends React.Component { newItem.name = griddleItem; this.griddleData.push(newItem); } - } } render (){ diff --git a/shared/adapter/ScoreMatrixGriddleAdapter.js b/shared/adapter/ScoreMatrixGriddleAdapter.js index 905a0e7..7abab8e 100644 --- a/shared/adapter/ScoreMatrixGriddleAdapter.js +++ b/shared/adapter/ScoreMatrixGriddleAdapter.js @@ -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) { @@ -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(); diff --git a/shared/adapter/TestSuitesGriddleAdapter.js b/shared/adapter/TestSuitesGriddleAdapter.js index 02642ae..675018b 100644 --- a/shared/adapter/TestSuitesGriddleAdapter.js +++ b/shared/adapter/TestSuitesGriddleAdapter.js @@ -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);