afterUpdate(inst /* , opts */) {
        const promiseArr = [];
        const cmds = [];
        const nameChanged = inst.previous('name') !== inst.getDataValue('name');
        const isPublishedChanged =
          inst.previous('isPublished') !== inst.getDataValue('isPublished');

        /*
         * When the sample store feature is enabled do the following
         * 1. if aspect name is changed and it is published, rename the entry
         * on aspectStore and the aspect hash.
         * 2. if the aspect is updated to published, add an entry to the
         * aspectStore and create the aspect hash
         * 3. if the aspect is updated to unpublished, delete the entry in the
         * aspectStore, delete the aspect hash and delete the related samples
         * 4. if the aspect that is updated is already published, update the
         * the aspect with the new values.
        */
        if (nameChanged && inst.isPublished) {
          const newAspName = inst.name;
          const oldAspectName = inst._previousDataValues.name;

          // rename entry in aspectStore
          promiseArr.push(redisOps.renameKey(aspectType,
            oldAspectName, newAspName));

          // duplicate aspect-to-subject resource map with new name
          promiseArr.push(redisOps.executeCommand(redisOps.duplicateSet(
            redisOps.aspSubMapType, newAspName, oldAspectName
          )));

          // add new aspect name entries to subject-to-aspect resource maps
          promiseArr.push(
            redisOps.executeCommand(
              redisOps.getAspSubjMapMembers(oldAspectName)
            )
            .map((subjAbsPath) => cmds.push(redisOps.addAspectNameInSubjectSet(
              subjAbsPath, newAspName)))
          );

          /*
           * delete multiple possible sample entries in the sample master
           * list of index and the related sample hashes. Deletes old aspect
           * name from subject-to-aspect resource maps. Deletes aspect-to-
           * subject resource map with old aspect name as key.
           */
          promiseArr.push(u.removeAspectRelatedSamples(
            inst._previousDataValues, seq));
        } else if (isPublishedChanged) {
          // Prevent any changes to original inst dataValues object
          const instDataObj = JSON.parse(JSON.stringify(inst.get()));
          promiseArr.push(redisOps.hmSet(aspectType, inst.name, instDataObj));

          // add the aspect to the aspect master list regardless of isPublished
          promiseArr.push(redisOps.addKey(aspectType, inst.name));
          if (!inst.isPublished) {
            /*
             * delete multiple possible sample entries in the sample master
             * list of index and the related sample hashes. Deletes aspect
             * name from subject-to-aspect resource maps. Deletes aspect-to-
             * subject resource map with aspect name as key.
             */
            promiseArr.push(u.removeAspectRelatedSamples(inst.dataValues, seq));
          }
        } else if (inst.isPublished) {
          const instChanged = {};
          Object.keys(inst._changed)
          .filter((key) => inst._changed[key])
          .forEach((key) => {
            instChanged[key] = inst[key];
          });
          promiseArr.push(redisOps.hmSet(aspectType, inst.name, instChanged));
        }

        /*
         * If aspect is published and tags change, send an "add" realtime
         * event for all the samples for this aspect. (The beforeUpdate hook
         * will already have sent a "delete" event.) This way, perspectives
         * which filter by aspect tags will get the right samples.
         */
        if (inst.isPublished && common.tagsChanged(inst)) {
          promiseArr.push(redisOps.getSamplesFromAspectName(inst.name)
            .each((samp) => {
              if (samp) {
                publishSample(
                  samp, seq.models.Subject, sampleEventNames.add,
                  seq.models.Aspect
                );
              }
            })
          );
        } // tags changed

        /* If aspect is published and any status range changes, delete the
         samples. Let the next new sample come in and recalculate status based
         on the new ranges.
         */
        if (inst.isPublished && (inst.changed('criticalRange') ||
         inst.changed('warningRange') || inst.changed('infoRange') ||
        inst.changed('okRange'))) {
          promiseArr.push(u.removeAspectRelatedSamples(inst.dataValues, seq));
        }

        return seq.Promise.all(promiseArr)
        .then(() => redisOps.executeBatchCmds(cmds));
      }
/**
       * If isPublished is being updated from true to false or the name of the
       * aspect is changed, delete any samples associated with the aspect.
       *
       * @param {Aspect} inst - The updated instance
       * @returns {Promise}
       */
If isPublished is being updated from true to false or the name of the
aspect is changed, delete any samples associated with the aspect.

@param {Aspect} inst - The updated instance
@returns {Promise}
If isPublished is being updated from true to false or the name of the aspect is changed delete any samples associated with the aspect . @param { Aspect } inst - The updated instance @returns { Promise }
afterUpdate(inst ) {
        const promiseArr = [];
        const cmds = [];
        const nameChanged = inst.previous('name') !== inst.getDataValue('name');
        const isPublishedChanged =
          inst.previous('isPublished') !== inst.getDataValue('isPublished');
        if (nameChanged && inst.isPublished) {
          const newAspName = inst.name;
          const oldAspectName = inst._previousDataValues.name;
          promiseArr.push(redisOps.renameKey(aspectType,
            oldAspectName, newAspName));
          promiseArr.push(redisOps.executeCommand(redisOps.duplicateSet(
            redisOps.aspSubMapType, newAspName, oldAspectName
          )));
          promiseArr.push(
            redisOps.executeCommand(
              redisOps.getAspSubjMapMembers(oldAspectName)
            )
            .map((subjAbsPath) => cmds.push(redisOps.addAspectNameInSubjectSet(
              subjAbsPath, newAspName)))
          );
          promiseArr.push(u.removeAspectRelatedSamples(
            inst._previousDataValues, seq));
        } else if (isPublishedChanged) {
          const instDataObj = JSON.parse(JSON.stringify(inst.get()));
          promiseArr.push(redisOps.hmSet(aspectType, inst.name, instDataObj));
          promiseArr.push(redisOps.addKey(aspectType, inst.name));
          if (!inst.isPublished) {
            promiseArr.push(u.removeAspectRelatedSamples(inst.dataValues, seq));
          }
        } else if (inst.isPublished) {
          const instChanged = {};
          Object.keys(inst._changed)
          .filter((key) => inst._changed[key])
          .forEach((key) => {
            instChanged[key] = inst[key];
          });
          promiseArr.push(redisOps.hmSet(aspectType, inst.name, instChanged));
        }
        if (inst.isPublished && common.tagsChanged(inst)) {
          promiseArr.push(redisOps.getSamplesFromAspectName(inst.name)
            .each((samp) => {
              if (samp) {
                publishSample(
                  samp, seq.models.Subject, sampleEventNames.add,
                  seq.models.Aspect
                );
              }
            })
          );
        } 
        if (inst.isPublished && (inst.changed('criticalRange') ||
         inst.changed('warningRange') || inst.changed('infoRange') ||
        inst.changed('okRange'))) {
          promiseArr.push(u.removeAspectRelatedSamples(inst.dataValues, seq));
        }
        return seq.Promise.all(promiseArr)
        .then(() => redisOps.executeBatchCmds(cmds));
      }
afterUpdate ( inst ) { const promiseArr = [ ] ; const cmds = [ ] ; const nameChanged = inst . previous ( 'name' ) !== inst . getDataValue ( 'name' ) ; const isPublishedChanged = inst . previous ( 'isPublished' ) !== inst . getDataValue ( 'isPublished' ) ; if ( nameChanged && inst . isPublished ) { const newAspName = inst . name ; const oldAspectName = inst . _previousDataValues . name ; promiseArr . push ( redisOps . renameKey ( aspectType , oldAspectName , newAspName ) ) ; promiseArr . push ( redisOps . executeCommand ( redisOps . duplicateSet ( redisOps . aspSubMapType , newAspName , oldAspectName ) ) ) ; promiseArr . push ( redisOps . executeCommand ( redisOps . getAspSubjMapMembers ( oldAspectName ) ) . map ( ( subjAbsPath ) => cmds . push ( redisOps . addAspectNameInSubjectSet ( subjAbsPath , newAspName ) ) ) ) ; promiseArr . push ( u . removeAspectRelatedSamples ( inst . _previousDataValues , seq ) ) ; } else if ( isPublishedChanged ) { const instDataObj = JSON . parse ( JSON . stringify ( inst . get ( ) ) ) ; promiseArr . push ( redisOps . hmSet ( aspectType , inst . name , instDataObj ) ) ; promiseArr . push ( redisOps . addKey ( aspectType , inst . name ) ) ; if ( ! inst . isPublished ) { promiseArr . push ( u . removeAspectRelatedSamples ( inst . dataValues , seq ) ) ; } } else if ( inst . isPublished ) { const instChanged = { } ; Object . keys ( inst . _changed ) . filter ( ( key ) => inst . _changed [ key ] ) . forEach ( ( key ) => { instChanged [ key ] = inst [ key ] ; } ) ; promiseArr . push ( redisOps . hmSet ( aspectType , inst . name , instChanged ) ) ; } if ( inst . isPublished && common . tagsChanged ( inst ) ) { promiseArr . push ( redisOps . getSamplesFromAspectName ( inst . name ) . each ( ( samp ) => { if ( samp ) { publishSample ( samp , seq . models . Subject , sampleEventNames . add , seq . models . Aspect ) ; } } ) ) ; } if ( inst . isPublished && ( inst . changed ( 'criticalRange' ) || inst . changed ( 'warningRange' ) || inst . changed ( 'infoRange' ) || inst . changed ( 'okRange' ) ) ) { promiseArr . push ( u . removeAspectRelatedSamples ( inst . dataValues , seq ) ) ; } return seq . Promise . all ( promiseArr ) . then ( ( ) => redisOps . executeBatchCmds ( cmds ) ) ; }
If isPublished is being updated from true to false or the name of the
 aspect is changed, delete any samples associated with the aspect.
If isPublished is being updated from true to false or the name of the aspect is changed delete any samples associated with the aspect .
/* , opts */ /*
         * When the sample store feature is enabled do the following
         * 1. if aspect name is changed and it is published, rename the entry
         * on aspectStore and the aspect hash.
         * 2. if the aspect is updated to published, add an entry to the
         * aspectStore and create the aspect hash
         * 3. if the aspect is updated to unpublished, delete the entry in the
         * aspectStore, delete the aspect hash and delete the related samples
         * 4. if the aspect that is updated is already published, update the
         * the aspect with the new values.
        */ // rename entry in aspectStore // duplicate aspect-to-subject resource map with new name // add new aspect name entries to subject-to-aspect resource maps /*
           * delete multiple possible sample entries in the sample master
           * list of index and the related sample hashes. Deletes old aspect
           * name from subject-to-aspect resource maps. Deletes aspect-to-
           * subject resource map with old aspect name as key.
           */ // Prevent any changes to original inst dataValues object // add the aspect to the aspect master list regardless of isPublished /*
             * delete multiple possible sample entries in the sample master
             * list of index and the related sample hashes. Deletes aspect
             * name from subject-to-aspect resource maps. Deletes aspect-to-
             * subject resource map with aspect name as key.
             */ /*
         * If aspect is published and tags change, send an "add" realtime
         * event for all the samples for this aspect. (The beforeUpdate hook
         * will already have sent a "delete" event.) This way, perspectives
         * which filter by aspect tags will get the right samples.
         */ // tags changed /* If aspect is published and any status range changes, delete the
         samples. Let the next new sample come in and recalculate status based
         on the new ranges.
         */