Skip to content

Commit fbc86f5

Browse files
committed
bugfix in scenario.export, group scenario params not by code but by id
1 parent 7fdca5f commit fbc86f5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

api/core/scenario/scenario.export.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ module.exports = function exportScenario(id){
2020
});
2121
};
2222

23-
function normalize(data){
23+
function normalize(data) {
2424
var newArray = [];
2525
var dictionnary = {};
2626
data.forEach(function(elem){
27-
if(dictionnary[elem.code]){
28-
dictionnary[elem.code].params[elem.variablename] = elem.value;
27+
if(dictionnary[elem.id]){
28+
dictionnary[elem.id].params[elem.variablename] = elem.value;
2929
} else {
30-
dictionnary[elem.code] = {
30+
dictionnary[elem.id] = {
3131
code: elem.code,
3232
params: {
3333
[elem.variablename]: elem.value
3434
}
3535
};
36-
newArray.push(dictionnary[elem.code]);
36+
newArray.push(dictionnary[elem.id]);
3737
}
3838
});
3939
return newArray;

api/core/scenario/scenario.queries.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
WHERE launcher.id = ?;
2828
`,
2929
getStates: `
30-
SELECT CONCAT(statetype.service, '.', statetype.function) as code, state.condition_template, state.active,
30+
SELECT state.id, CONCAT(statetype.service, '.', statetype.function) as code, state.condition_template, state.active,
3131
stateparam.value, statetypeparam.variablename
3232
FROM state
3333
JOIN statetype ON state.state = statetype.id
@@ -37,7 +37,7 @@ module.exports = {
3737
`,
3838
getActions:
3939
`
40-
SELECT CONCAT(actiontype.service, '.', actiontype.function) as code, actionparam.value, actiontypeparam.variablename
40+
SELECT action.id, CONCAT(actiontype.service, '.', actiontype.function) as code, actionparam.value, actiontypeparam.variablename
4141
FROM action
4242
JOIN actiontype ON action.action = actiontype.id
4343
JOIN actionparam ON actionparam.action = action.id

0 commit comments

Comments
 (0)