function assignUnassignedGenerators() {
  // finds all unassigned generators (those with no currentCollector).
  // Use collectorId because it's a field on the db model, vs currentCollector
  // which is an association and can't be looked up with a normal where clause

  if (featureToggles.isFeatureEnabled('distributeGenerators')) {
    return utils.seq.models.Generator.findAll(
      { where: { isActive: true, collectorId: null } }
    ).map((g) => g.assignToCollector()
      .then(() => g.save()));
  }

  return utils.seq.models.Generator.findAll(
    { where: { isActive: true, collectorId: null } }
  ).map((g) => {
    g.assignToCollector();
    return g.save();
  });
}
/**
 * Find unassigned generators and assign them.
 * @returns {Promise} - Resolves to array of assigned generator db objects
 */
Find unassigned generators and assign them.
@returns {Promise} - Resolves to array of assigned generator db objects
Find unassigned generators and assign them . @returns { Promise } - Resolves to array of assigned generator db objects
function assignUnassignedGenerators() {
  if (featureToggles.isFeatureEnabled('distributeGenerators')) {
    return utils.seq.models.Generator.findAll(
      { where: { isActive: true, collectorId: null } }
    ).map((g) => g.assignToCollector()
      .then(() => g.save()));
  }
  return utils.seq.models.Generator.findAll(
    { where: { isActive: true, collectorId: null } }
  ).map((g) => {
    g.assignToCollector();
    return g.save();
  });
}
function assignUnassignedGenerators ( ) { if ( featureToggles . isFeatureEnabled ( 'distributeGenerators' ) ) { return utils . seq . models . Generator . findAll ( { where : { isActive : true , collectorId : null } } ) . map ( ( g ) => g . assignToCollector ( ) . then ( ( ) => g . save ( ) ) ) ; } return utils . seq . models . Generator . findAll ( { where : { isActive : true , collectorId : null } } ) . map ( ( g ) => { g . assignToCollector ( ) ; return g . save ( ) ; } ) ; }
Find unassigned generators and assign them.
Find unassigned generators and assign them .
// finds all unassigned generators (those with no currentCollector). // Use collectorId because it's a field on the db model, vs currentCollector // which is an association and can't be looked up with a normal where clause