Skip to content

Commit

Permalink
bugfix in scenario.export, group scenario params not by code but by id
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Oct 16, 2017
1 parent 7fdca5f commit fbc86f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions api/core/scenario/scenario.export.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ module.exports = function exportScenario(id){
});
};

function normalize(data){
function normalize(data) {
var newArray = [];
var dictionnary = {};
data.forEach(function(elem){
if(dictionnary[elem.code]){
dictionnary[elem.code].params[elem.variablename] = elem.value;
if(dictionnary[elem.id]){
dictionnary[elem.id].params[elem.variablename] = elem.value;
} else {
dictionnary[elem.code] = {
dictionnary[elem.id] = {
code: elem.code,
params: {
[elem.variablename]: elem.value
}
};
newArray.push(dictionnary[elem.code]);
newArray.push(dictionnary[elem.id]);
}
});
return newArray;
Expand Down
4 changes: 2 additions & 2 deletions api/core/scenario/scenario.queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
WHERE launcher.id = ?;
`,
getStates: `
SELECT CONCAT(statetype.service, '.', statetype.function) as code, state.condition_template, state.active,
SELECT state.id, CONCAT(statetype.service, '.', statetype.function) as code, state.condition_template, state.active,
stateparam.value, statetypeparam.variablename
FROM state
JOIN statetype ON state.state = statetype.id
Expand All @@ -37,7 +37,7 @@ module.exports = {
`,
getActions:
`
SELECT CONCAT(actiontype.service, '.', actiontype.function) as code, actionparam.value, actiontypeparam.variablename
SELECT action.id, CONCAT(actiontype.service, '.', actiontype.function) as code, actionparam.value, actiontypeparam.variablename
FROM action
JOIN actiontype ON action.action = actiontype.id
JOIN actionparam ON actionparam.action = action.id
Expand Down

0 comments on commit fbc86f5

Please sign in to comment.