<commit_before>const R = require('ramda');
const model = require('davis-model');
const { dataSet, folder, variable, attribute } = model;
const q = model.query.build;
const Task = require('data.task');
const Async = require('control.async')(Task);
const when = require('when');
const task2Promise = Async.toPromise(when.promise);
const shared = require('davis-shared');
const {thread} = shared.fp;
const entityLoaderFactory = require('./entityLoaderFactory');

module.exports = ({
  entityRepository
}) => {

  const entityLoaders = entityLoaderFactory(entityRepository, [
    dataSet.entityType,
    folder.entityType,
    variable.entityType,
    attribute.entityType
  ]);

  // Reads
  const resolveEntityFromId = (propertyName, entityType, props) => {
      const id = props[propertyName];
      if(R.isNil(id)){
        return null;
      }
      return entityLoaders[entityType].load(props[propertyName]);
    };

  const resolveAttributesFromVariable = id => task2Promise(entityRepository.query(
    attribute.entityType,
    q.eq('variable', id)));<commit_msg>Fix spacing<commit_after>const R = require('ramda');
const model = require('davis-model');
const { dataSet, folder, variable, attribute } = model;
const q = model.query.build;
const Task = require('data.task');
const Async = require('control.async')(Task);
const when = require('when');
const task2Promise = Async.toPromise(when.promise);
const shared = require('davis-shared');
const {thread} = shared.fp;
const entityLoaderFactory = require('./entityLoaderFactory');

module.exports = ({
  entityRepository
}) => {

  const entityLoaders = entityLoaderFactory(entityRepository, [
    dataSet.entityType,
    folder.entityType,
    variable.entityType,
    attribute.entityType
  ]);

  // Reads
  const resolveEntityFromId = (propertyName, entityType, props) => {
    const id = props[propertyName];
    if(R.isNil(id)){
      return null;
    }
    return entityLoaders[entityType].load(props[propertyName]);
  };

  const resolveAttributesFromVariable = id => task2Promise(entityRepository.query(
    attribute.entityType,
    q.eq('variable', id)));
{'fraction_non_alphanumeric': 0.13854853911404336, 'fraction_numerical': 0.001885014137606032, 'mean_word_length': 4.616402116402116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6415646', 'n_tokens_mistral': 613, 'n_tokens_neox': 605, 'n_words': 132}