function doGetHierarchy(resultObj) {
  const params = resultObj.params;
  const depth = Number(params.depth.value);
  resultObj.dbStartTime = Date.now();

  const fields = params.fields.value;
  const filterFields = fields && fields.length;
  const subjectTags = params.subjectTags.value;
  const filterByTags = subjectTags && subjectTags.length;
  const excludedFields = [];

  if (filterFields) {
    // if createdBy field is excluded, need to add it for the SQL query to work
    if (!fields.includes('createdBy')) {
      excludedFields.push('createdBy');
    }

    // if absolutePath field is excluded, need to add it for the SQL query to work
    if (!fields.includes('absolutePath')) {
      excludedFields.push('absolutePath');
    }

    // if tags field is excluded, need to add it so we can filter by tags later
    if (filterByTags && !fields.includes('tags')) {
      excludedFields.push('tags');
    }

    excludedFields.forEach((f) => fields.push(f));
  }

  return u.findByKey(helper, params, ['hierarchy'])
    .then((o) => {
      resultObj.dbEndTime = Date.now();
      resultObj.dbTime = resultObj.dbEndTime - resultObj.dbStartTime;
      resultObj.recordCount = 1;
      let retval = u.responsify(o, helper, GET);
      if (depth > ZERO) {
        retval = helper.deleteChildren(retval, depth);
      }

      return redisSubjectModel.completeSubjectHierarchy(retval, params)
      .then((_retval) => {
        resultObj.retval = _retval;
        excludedFields.forEach((f) => delete retval[f]);
        return resultObj;
      });
    });
} // doGetHierarchy
/**
 * Retrieves the subject with all its descendents included.
 *
 * @param {Object} resultObj - The result Object
 */
Retrieves the subject with all its descendents included.
@param {Object} resultObj - The result Object
Retrieves the subject with all its descendents included . @param { Object } resultObj - The result Object
function doGetHierarchy(resultObj) {
  const params = resultObj.params;
  const depth = Number(params.depth.value);
  resultObj.dbStartTime = Date.now();
  const fields = params.fields.value;
  const filterFields = fields && fields.length;
  const subjectTags = params.subjectTags.value;
  const filterByTags = subjectTags && subjectTags.length;
  const excludedFields = [];
  if (filterFields) {
    if (!fields.includes('createdBy')) {
      excludedFields.push('createdBy');
    }
    if (!fields.includes('absolutePath')) {
      excludedFields.push('absolutePath');
    }
    if (filterByTags && !fields.includes('tags')) {
      excludedFields.push('tags');
    }
    excludedFields.forEach((f) => fields.push(f));
  }
  return u.findByKey(helper, params, ['hierarchy'])
    .then((o) => {
      resultObj.dbEndTime = Date.now();
      resultObj.dbTime = resultObj.dbEndTime - resultObj.dbStartTime;
      resultObj.recordCount = 1;
      let retval = u.responsify(o, helper, GET);
      if (depth > ZERO) {
        retval = helper.deleteChildren(retval, depth);
      }
      return redisSubjectModel.completeSubjectHierarchy(retval, params)
      .then((_retval) => {
        resultObj.retval = _retval;
        excludedFields.forEach((f) => delete retval[f]);
        return resultObj;
      });
    });
} 
function doGetHierarchy ( resultObj ) { const params = resultObj . params ; const depth = Number ( params . depth . value ) ; resultObj . dbStartTime = Date . now ( ) ; const fields = params . fields . value ; const filterFields = fields && fields . length ; const subjectTags = params . subjectTags . value ; const filterByTags = subjectTags && subjectTags . length ; const excludedFields = [ ] ; if ( filterFields ) { if ( ! fields . includes ( 'createdBy' ) ) { excludedFields . push ( 'createdBy' ) ; } if ( ! fields . includes ( 'absolutePath' ) ) { excludedFields . push ( 'absolutePath' ) ; } if ( filterByTags && ! fields . includes ( 'tags' ) ) { excludedFields . push ( 'tags' ) ; } excludedFields . forEach ( ( f ) => fields . push ( f ) ) ; } return u . findByKey ( helper , params , [ 'hierarchy' ] ) . then ( ( o ) => { resultObj . dbEndTime = Date . now ( ) ; resultObj . dbTime = resultObj . dbEndTime - resultObj . dbStartTime ; resultObj . recordCount = 1 ; let retval = u . responsify ( o , helper , GET ) ; if ( depth > ZERO ) { retval = helper . deleteChildren ( retval , depth ) ; } return redisSubjectModel . completeSubjectHierarchy ( retval , params ) . then ( ( _retval ) => { resultObj . retval = _retval ; excludedFields . forEach ( ( f ) => delete retval [ f ] ) ; return resultObj ; } ) ; } ) ; }
Retrieves the subject with all its descendents included.
Retrieves the subject with all its descendents included .
// if createdBy field is excluded, need to add it for the SQL query to work // if absolutePath field is excluded, need to add it for the SQL query to work // if tags field is excluded, need to add it so we can filter by tags later // doGetHierarchy