function activityCouldHaveLaps(
  activity,
  verbose = false,
  overrideLocations,
) {
  const activityHas = (key) => _has(activity, key);

  const {
    id,
    type,
    trainer,
    manual,
  } = activity;

  // First make sure it has an id
  if (!activityHas('id')) {
    return false;
  }

  let reason = '';
  if (activityHas('type') && type.toLowerCase() !== 'ride') {
    reason = `Activity ${id} is not a Ride.`;
  } else if (activityHas('manual') && manual) {
    reason = `Activity ${id} is a manual activity.`;
  } else if (activityHas('trainer') && trainer) {
    reason = `Activity ${id} is a trainer activity.`;
  }

  if (reason) {
    if (verbose) {
      console.log(reason);
    }
    return false;
  }

  if (
    activityHas('distance')
    && activityHas('start_latlng')
    && activityHas('end_latlng')
  ) {
    const potentials = findPotentialLocations(
      activity,
      {
        verbose,
        locations: overrideLocations,
      },
    );
    return potentials.length > 0;
  }

  return true;
}
/**
 * Check where an activity is eligible to maybe have laps.
 * Keep it eligible for future checking
 * e.g. can't disqualify unless a property is *set* to a value we don't want
 *
 * @param {Object} activity
 * @param {Bool} verbose
 * @param {Object} overrideLocations Will replace default locations when checking findPotentialLocations
 * @return {Boolean} True if activity has the right attrs and is near at least one location
 */
Check where an activity is eligible to maybe have laps.
Keep it eligible for future checking
e.g. can't disqualify unless a property is *set* to a value we don't want

@param {Object} activity
@param {Bool} verbose
@param {Object} overrideLocations Will replace default locations when checking findPotentialLocations
@return {Boolean} True if activity has the right attrs and is near at least one location
Check where an activity is eligible to maybe have laps . Keep it eligible for future checking e . g . can ' t disqualify unless a property is * set * to a value we don ' t want @param { Object } activity @param { Bool } verbose @param { Object } overrideLocations Will replace default locations when checking findPotentialLocations @return { Boolean } True if activity has the right attrs and is near at least one location
function activityCouldHaveLaps(
  activity,
  verbose = false,
  overrideLocations,
) {
  const activityHas = (key) => _has(activity, key);
  const {
    id,
    type,
    trainer,
    manual,
  } = activity;
  if (!activityHas('id')) {
    return false;
  }
  let reason = '';
  if (activityHas('type') && type.toLowerCase() !== 'ride') {
    reason = `Activity ${id} is not a Ride.`;
  } else if (activityHas('manual') && manual) {
    reason = `Activity ${id} is a manual activity.`;
  } else if (activityHas('trainer') && trainer) {
    reason = `Activity ${id} is a trainer activity.`;
  }
  if (reason) {
    if (verbose) {
      console.log(reason);
    }
    return false;
  }
  if (
    activityHas('distance')
    && activityHas('start_latlng')
    && activityHas('end_latlng')
  ) {
    const potentials = findPotentialLocations(
      activity,
      {
        verbose,
        locations: overrideLocations,
      },
    );
    return potentials.length > 0;
  }
  return true;
}
function activityCouldHaveLaps ( activity , verbose = false , overrideLocations , ) { const activityHas = ( key ) => _has ( activity , key ) ; const { id , type , trainer , manual , } = activity ; if ( ! activityHas ( 'id' ) ) { return false ; } let reason = '' ; if ( activityHas ( 'type' ) && type . toLowerCase ( ) !== 'ride' ) { reason = ` ${ id } ` ; } else if ( activityHas ( 'manual' ) && manual ) { reason = ` ${ id } ` ; } else if ( activityHas ( 'trainer' ) && trainer ) { reason = ` ${ id } ` ; } if ( reason ) { if ( verbose ) { console . log ( reason ) ; } return false ; } if ( activityHas ( 'distance' ) && activityHas ( 'start_latlng' ) && activityHas ( 'end_latlng' ) ) { const potentials = findPotentialLocations ( activity , { verbose , locations : overrideLocations , } , ) ; return potentials . length > 0 ; } return true ; }
Check where an activity is eligible to maybe have laps.
Check where an activity is eligible to maybe have laps .
// First make sure it has an id