<commit_before>import { createSelector } from 'reselect';
import { fromJS } from 'immutable';

export const selectApp = (state) => state.get('App');

export const selectLocationState = () => {
  let prevRoutingState;
  let prevRoutingStateJS;

  return (state) => {
    const routingState = state.get('route');

    if (!routingState.equals(prevRoutingState)) {
      prevRoutingState = routingState;
      prevRoutingStateJS = routingState.toJS();
    }

    return prevRoutingStateJS;
  };
};

export const selectDrawerOpen = createSelector(
  selectApp,
  (globalState) => globalState.get('drawerOpen')
);

export const selectNodesMetadata = createSelector(
  selectApp,
  (globalState) => globalState.get('nodesMetadata')
);

export const selectNodeMetadata = createSelector(
  selectNodesMetadata,
  (nodesMetadata) => (nodeId) => nodesMetadata.get(nodeId, fromJS({}))
);

export const selectNodeName = createSelector(
  selectNodeMetadata,
  (getNodeMetadata) => (nodeId) => getNodeMetadata(nodeId).get('name', '')
);

export const selectNodeMeasurements = createSelector(
  selectNodeMetadata,
  (getNodeMetadata) => (nodeId) => getNodeMetadata(nodeId).get('measurements', fromJS([]))
);

export const selectNodePosition = createSelector(
  selectNodeMetadata,
  (getNodeMetadata) => (nodeId) => getNodeMetadata(nodeId).get('position', fromJS({}))
);

export const selectNodePositionX = createSelector(
  selectNodePosition,
  (getNodePosition) => (nodeId) => getNodePosition(nodeId).get('x', null)
)

export const selectNodePositionY = createSelector(
  selectNodePosition,
  (getNodePosition) => (nodeId) => getNodePosition(nodeId).get('y', null)
)

export const selectTreeStructure = createSelector(
  selectApp,
  (globalState) => globalState.get('treeStructure')
);

export const selectTreeTimestamp = createSelector(
  selectApp,
  (globalState) => globalState.get('treeTimestamp')
);

export const selectMeasurementsMetadata = createSelector(
  selectApp,
  (globalState) => globalState.get('measurementsMetadata')
);

export const selectMeasurementMetadata = createSelector(
  selectMeasurementsMetadata,
  (measurementsMetadata) => (measurementId) => measurementsMetadata.get(measurementId, fromJS({}))
)

export const selectMeasurementName = createSelector(
  selectMeasurementMetadata,
  (getMeasurementMetadata) => (measurementId) => getMeasurementMetadata(measurementId).get('name', '')
)

export const selectRequestedData = createSelector(
  selectApp,
  (globalState) => globalState.get('requestedData')
)

export const selectRequestData = createSelector(
  selectRequestedData,
  (requestedData) => (requestId) => requestedData.get(requestId, fromJS({}))
)

export const selectRequestLiveData = createSelector(
  selectRequestData,
  (getRequestData) => (requestId) =>
    getRequestData(requestId).get('type', '') === 'new_live_data' ? getRequestData(requestId).get('data', fromJS({})) : fromJS({})
)

export const selectRequestLiveDataValue = createSelector(
  selectRequestLiveData,
  (getRequestLiveData) => (requestId) => getRequestLiveData(requestId).get('value', null)
)

export const selectRequestLiveDataTimestamp = createSelector(
  selectRequestLiveData,
  (getRequestLiveData) => (requestId) => getRequestLiveData(requestId).get('timestamp', null)
)

export const selectActiveNodeId = createSelector(
  selectApp,
  (globalState) => globalState.get('activeNodeId')
);

function getSubTree(tree, subtreeId) {
  if (subtreeId) {
    // Traverse all roots (our data tree is actually a forest)
    for (var i = 0; i < tree.size; i++) {
      // If we found node with given id, we can return a tree rooted at that node
      if (tree.get(i).get('node_id') === subtreeId) {<commit_msg>Delete unused App selectors<commit_after>import { createSelector } from 'reselect';
import { fromJS } from 'immutable';

export const selectApp = (state) => state.get('App');

export const selectLocationState = () => {
  let prevRoutingState;
  let prevRoutingStateJS;

  return (state) => {
    const routingState = state.get('route');

    if (!routingState.equals(prevRoutingState)) {
      prevRoutingState = routingState;
      prevRoutingStateJS = routingState.toJS();
    }

    return prevRoutingStateJS;
  };
};

export const selectDrawerOpen = createSelector(
  selectApp,
  (globalState) => globalState.get('drawerOpen')
);

export const selectNodesMetadata = createSelector(
  selectApp,
  (globalState) => globalState.get('nodesMetadata')
);

export const selectNodeMetadata = createSelector(
  selectNodesMetadata,
  (nodesMetadata) => (nodeId) => nodesMetadata.get(nodeId, fromJS({}))
);

export const selectNodeName = createSelector(
  selectNodeMetadata,
  (getNodeMetadata) => (nodeId) => getNodeMetadata(nodeId).get('name', '')
);

export const selectNodeMeasurements = createSelector(
  selectNodeMetadata,
  (getNodeMetadata) => (nodeId) => getNodeMetadata(nodeId).get('measurements', fromJS([]))
);

export const selectNodePosition = createSelector(
  selectNodeMetadata,
  (getNodeMetadata) => (nodeId) => getNodeMetadata(nodeId).get('position', fromJS({}))
);

export const selectNodePositionX = createSelector(
  selectNodePosition,
  (getNodePosition) => (nodeId) => getNodePosition(nodeId).get('x', null)
)

export const selectNodePositionY = createSelector(
  selectNodePosition,
  (getNodePosition) => (nodeId) => getNodePosition(nodeId).get('y', null)
)

export const selectTreeStructure = createSelector(
  selectApp,
  (globalState) => globalState.get('treeStructure')
);

export const selectTreeTimestamp = createSelector(
  selectApp,
  (globalState) => globalState.get('treeTimestamp')
);

export const selectMeasurementsMetadata = createSelector(
  selectApp,
  (globalState) => globalState.get('measurementsMetadata')
);

export const selectMeasurementMetadata = createSelector(
  selectMeasurementsMetadata,
  (measurementsMetadata) => (measurementId) => measurementsMetadata.get(measurementId, fromJS({}))
)

export const selectMeasurementName = createSelector(
  selectMeasurementMetadata,
  (getMeasurementMetadata) => (measurementId) => getMeasurementMetadata(measurementId).get('name', '')
)

export const selectActiveNodeId = createSelector(
  selectApp,
  (globalState) => globalState.get('activeNodeId')
);

function getSubTree(tree, subtreeId) {
  if (subtreeId) {
    // Traverse all roots (our data tree is actually a forest)
    for (var i = 0; i < tree.size; i++) {
      // If we found node with given id, we can return a tree rooted at that node
      if (tree.get(i).get('node_id') === subtreeId) {
{'fraction_non_alphanumeric': 0.12823636917453549, 'fraction_numerical': 0.0003045994517209869, 'mean_word_length': 5.869246861924686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1200876', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1916, 'n_words': 421}