1) Changing the state of the react directly is not recommended, so avoid changing it directly.

2) Fixed API test cases.
This commit is contained in:
Aditya Toshniwal
2020-09-09 13:08:58 +05:30
committed by Akshay Joshi
parent 535739c0c7
commit 796a8a013a
2 changed files with 14 additions and 8 deletions

View File

@@ -80,15 +80,20 @@ export function statsReducer(state, action) {
action.counterData = action.incoming;
}
let newState = {};
Object.keys(action.incoming).forEach(label => {
let newEle = action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label];
state[label] = state[label] || [];
if(state[label].length >= X_AXIS_LENGTH) {
state[label].pop();
if(state[label]) {
newState[label] = [
action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label],
...state[label].slice(0, X_AXIS_LENGTH-1),
];
} else {
newState[label] = [
action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label],
];
}
state[label].unshift(newEle);
});
return state;
return newState;
}
const chartsDefault = {

View File

@@ -1167,8 +1167,9 @@ WHERE db.datname = current_database()""")
rows = []
self.row_count = cur.rowcount
for row in cur:
rows.append(dict(row))
if cur.rowcount > 0:
for row in cur:
rows.append(dict(row))
return True, {'columns': columns, 'rows': rows}