From 460a376903e7e56ff18790deb8205f9c13b09f63 Mon Sep 17 00:00:00 2001 From: olav Date: Wed, 9 Feb 2022 14:48:32 +0100 Subject: [PATCH] refactor: remove unused feature metrics state (#690) --- frontend/src/store/feature-metrics/actions.js | 54 ------------------- frontend/src/store/feature-metrics/api.js | 23 -------- frontend/src/store/feature-metrics/index.js | 23 -------- frontend/src/store/index.js | 2 - 4 files changed, 102 deletions(-) delete mode 100644 frontend/src/store/feature-metrics/actions.js delete mode 100644 frontend/src/store/feature-metrics/api.js delete mode 100644 frontend/src/store/feature-metrics/index.js diff --git a/frontend/src/store/feature-metrics/actions.js b/frontend/src/store/feature-metrics/actions.js deleted file mode 100644 index de3eee76ef..0000000000 --- a/frontend/src/store/feature-metrics/actions.js +++ /dev/null @@ -1,54 +0,0 @@ -import api from './api'; - -export const START_FETCH_FEATURE_METRICS = 'START_FETCH_FEATURE_METRICS'; -export const RECEIVE_FEATURE_METRICS = 'RECEIVE_FEATURE_METRICS'; -export const ERROR_FETCH_FEATURE_METRICS = 'ERROR_FETCH_FEATURE_METRICS'; - -export const START_FETCH_SEEN_APP = 'START_FETCH_SEEN_APP'; -export const RECEIVE_SEEN_APPS = 'RECEIVE_SEEN_APPS'; -export const ERROR_FETCH_SEEN_APP = 'ERROR_FETCH_SEEN_APP'; - -function receiveFeatureMetrics(json) { - return { - type: RECEIVE_FEATURE_METRICS, - value: json, - receivedAt: Date.now(), - }; -} - -function receiveSeenApps(json) { - return { - type: RECEIVE_SEEN_APPS, - value: json, - receivedAt: Date.now(), - }; -} - -function dispatchAndThrow(dispatch, type) { - return error => { - dispatch({ type, error, receivedAt: Date.now() }); - // throw error; - }; -} - -export function fetchFeatureMetrics() { - return dispatch => { - dispatch({ type: START_FETCH_FEATURE_METRICS }); - - return api - .fetchFeatureMetrics() - .then(json => dispatch(receiveFeatureMetrics(json))) - .catch(dispatchAndThrow(dispatch, ERROR_FETCH_FEATURE_METRICS)); - }; -} - -export function fetchSeenApps() { - return dispatch => { - dispatch({ type: START_FETCH_SEEN_APP }); - - return api - .fetchSeenApps() - .then(json => dispatch(receiveSeenApps(json))) - .catch(dispatchAndThrow(dispatch, ERROR_FETCH_SEEN_APP)); - }; -} diff --git a/frontend/src/store/feature-metrics/api.js b/frontend/src/store/feature-metrics/api.js deleted file mode 100644 index 3fe10dd7ca..0000000000 --- a/frontend/src/store/feature-metrics/api.js +++ /dev/null @@ -1,23 +0,0 @@ -import { formatApiPath } from '../../utils/format-path'; -import { throwIfNotSuccess } from '../api-helper'; - -const URI = formatApiPath('api/admin/metrics/feature-toggles'); - -function fetchFeatureMetrics() { - return fetch(URI, { credentials: 'include' }) - .then(throwIfNotSuccess) - .then(response => response.json()); -} - -const seenURI = formatApiPath('api/admin/metrics/seen-apps'); - -function fetchSeenApps() { - return fetch(seenURI, { credentials: 'include' }) - .then(throwIfNotSuccess) - .then(response => response.json()); -} - -export default { - fetchFeatureMetrics, - fetchSeenApps, -}; diff --git a/frontend/src/store/feature-metrics/index.js b/frontend/src/store/feature-metrics/index.js deleted file mode 100644 index 5a51c56d04..0000000000 --- a/frontend/src/store/feature-metrics/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import { Map as $Map, fromJS } from 'immutable'; - -import { RECEIVE_FEATURE_METRICS, RECEIVE_SEEN_APPS } from './actions'; - -const metrics = ( - state = fromJS({ lastHour: {}, lastMinute: {}, seenApps: {} }), - action -) => { - switch (action.type) { - case RECEIVE_SEEN_APPS: - return state.set('seenApps', new $Map(action.value)); - case RECEIVE_FEATURE_METRICS: - return state.withMutations(ctx => { - ctx.set('lastHour', new $Map(action.value.lastHour)); - ctx.set('lastMinute', new $Map(action.value.lastMinute)); - return ctx; - }); - default: - return state; - } -}; - -export default metrics; diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 98be9e9f04..326d8cef67 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -1,6 +1,5 @@ import { combineReducers } from 'redux'; import features from './feature-toggle'; -import featureMetrics from './feature-metrics'; import tagTypes from './tag-type'; import tags from './tag'; import strategies from './strategy'; @@ -13,7 +12,6 @@ import apiCalls from './api-calls'; const unleashStore = combineReducers({ features, - featureMetrics, strategies, tagTypes, tags,