src/connectors/appscript-connector.js
/**
   * appendResultList - Append new results to the end of the existing Results.
   * @param  {Array<object>} newResults Array of new Results
   *
   * Available options:
   * - options.appscript.spreadArrayProperty {string}: To specify a property
   *     key for spreading an array of metrics into multiple rows of single
   *     metric object.
   */
Append new results to the end of the existing Results.
@param  {Array} newResults Array of new Results

Available options:
- options.appscript.spreadArrayProperty {string}: To specify a property
key for spreading an array of metrics into multiple rows of single
metric object.
Append new results to the end of the existing Results . @param { Array } newResults Array of new Results Available options : - options . appscript . spreadArrayProperty { string } : To specify a property key for spreading an array of metrics into multiple rows of single metric object .
appendResultList(newResults, options) {
    options = options || {};
    let appscript = options.appscript || {};
    let resultsToUpdate = [];
    let tabId = appscript.resultsTab || this.defaultResultsTab;
    let tabConfig = this.tabConfigs[tabId];
    if (appscript.spreadArrayProperty) {
      newResults.forEach(result => {
        try {
          let spreadArray = eval(`result.${appscript.spreadArrayProperty}`);
          if (Array.isArray(spreadArray) && spreadArray.length > 0) {
            for (let i = 0; i <spreadArray.length; i++) {
              let newResult = JSON.parse(JSON.stringify(result));
              if (i > 0) newResult.status = Status.DUPLICATE;
              eval(`newResult.${appscript.spreadArrayProperty} = spreadArray[i]`);
              resultsToUpdate.push(newResult);
            }
          } else {
            resultsToUpdate.push(result);
          }
        } catch (e) {
          resultsToUpdate.push(result);
        }
      });
    } else {
      resultsToUpdate = newResults;
    }
    let lastRowIndex = this.getTabLastRow(tabId) + 1;
    this.appendList(tabId, resultsToUpdate, (result, rowIndex) => {
      rowIndex = lastRowIndex;
      lastRowIndex++;
      return rowIndex;
    } );
  }
appendResultList ( newResults , options ) { options = options || { } ; let appscript = options . appscript || { } ; let resultsToUpdate = [ ] ; let tabId = appscript . resultsTab || this . defaultResultsTab ; let tabConfig = this . tabConfigs [ tabId ] ; if ( appscript . spreadArrayProperty ) { newResults . forEach ( result => { try { let spreadArray = eval ( ` ${ appscript . spreadArrayProperty } ` ) ; if ( Array . isArray ( spreadArray ) && spreadArray . length > 0 ) { for ( let i = 0 ; i < spreadArray . length ; i ++ ) { let newResult = JSON . parse ( JSON . stringify ( result ) ) ; if ( i > 0 ) newResult . status = Status . DUPLICATE ; eval ( ` ${ appscript . spreadArrayProperty } ` ) ; resultsToUpdate . push ( newResult ) ; } } else { resultsToUpdate . push ( result ) ; } } catch ( e ) { resultsToUpdate . push ( result ) ; } } ) ; } else { resultsToUpdate = newResults ; } let lastRowIndex = this . getTabLastRow ( tabId ) + 1 ; this . appendList ( tabId , resultsToUpdate , ( result , rowIndex ) => { rowIndex = lastRowIndex ; lastRowIndex ++ ; return rowIndex ; } ) ; }
appendResultList - Append new results to the end of the existing Results.
appendResultList - Append new results to the end of the existing Results .
// If tabId is not specified, use the default Results tabId. // Spread arrays into multple rows if specific properties are arrays. // Break a result into multiple Duplicate rows, and keep the first row // as the original status. // Adding entire result if the spreadArrayProperty has not value. // Use the last row index as base for appending results. /* rowIndexFunc */