<commit_before>import R from 'ramda';

import {
  PIN_DIRECTION,
  PROPERTY_TYPE,
  SIZE,
  NODE_CATEGORY,
  NODETYPE_ERRORS,
  LINK_ERRORS,
} from './constants';

import { deepMerge } from '../utils/ramda';

export const getUserName = R.always('Bob');

/*
  Common utils
*/
export const indexById = R.indexBy(R.prop('id'));
const findByProp = (propName, propVal, from) => R.pipe(
  R.values,
  R.find(R.propEq(propName, propVal))
)(from);

const findById = (id, from) => findByProp('id', id, from);
const findByPatchId = (id, from) => findByProp('patchId', id, from);
const findByNodeTypeId = (id, from) => findByProp('typeId', id, from);

const getProjectState = (state, path) => {
  if (path.length > 0 && R.has(path[0], state)) {
    return getProjectState(
      R.prop(path.shift(), state),
      path
    );
  }
  return state;
};

export const getProject = (state) => {
  const path = ['project', 'present'];
  return getProjectState(state, path);
};

export const getPatches = R.pipe(
  getProject,
  R.prop('patches')
);

export const getPatchById = R.curry(<commit_msg>fix(eslint): fix eslint error about unused method<commit_after>import R from 'ramda';

import {
  PIN_DIRECTION,
  PROPERTY_TYPE,
  SIZE,
  NODE_CATEGORY,
  NODETYPE_ERRORS,
  LINK_ERRORS,
} from './constants';

import { deepMerge } from '../utils/ramda';

export const getUserName = R.always('Bob');

/*
  Common utils
*/
export const indexById = R.indexBy(R.prop('id'));
const findByProp = (propName, propVal, from) => R.pipe(
  R.values,
  R.find(R.propEq(propName, propVal))
)(from);

const findById = (id, from) => findByProp('id', id, from);
const findByNodeTypeId = (id, from) => findByProp('typeId', id, from);

const getProjectState = (state, path) => {
  if (path.length > 0 && R.has(path[0], state)) {
    return getProjectState(
      R.prop(path.shift(), state),
      path
    );
  }
  return state;
};

export const getProject = (state) => {
  const path = ['project', 'present'];
  return getProjectState(state, path);
};

export const getPatches = R.pipe(
  getProject,
  R.prop('patches')
);

export const getPatchById = R.curry(
{'fraction_non_alphanumeric': 0.16455101081335213, 'fraction_numerical': 0.0018805829807240243, 'mean_word_length': 4.090909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '1448046', 'n_tokens_mistral': 776, 'n_tokens_neox': 768, 'n_words': 188}