1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-23 20:07:40 +02:00
unleash.unleash/frontend/src/store/feature-metrics-store.js

25 lines
721 B
JavaScript
Raw Normal View History

2016-11-10 14:26:24 +01:00
import { Map as $Map, fromJS } from 'immutable';
import {
RECEIVE_FEATURE_METRICS,
2016-12-05 14:19:19 +01:00
RECEIVE_SEEN_APPS,
2016-11-10 14:26:24 +01:00
} from './feature-metrics-actions';
2016-12-05 14:19:19 +01:00
const metrics = (state = fromJS({ lastHour: {}, lastMinute: {}, seenApps: {} }), action) => {
2016-11-10 14:26:24 +01:00
switch (action.type) {
2016-12-05 14:19:19 +01:00
case RECEIVE_SEEN_APPS:
return state.set('seenApps', new $Map(action.value));
2016-11-10 14:26:24 +01:00
case RECEIVE_FEATURE_METRICS:
return state.withMutations((ctx) => {
2016-12-05 14:19:19 +01:00
ctx.set('lastHour', new $Map(action.value.lastHour));
ctx.set('lastMinute', new $Map(action.value.lastMinute));
2016-11-10 14:26:24 +01:00
return ctx;
});
default:
return state;
}
};
export default metrics;