processEffort(effortRaw) {
    const {
      activity = false,
      start_date = false,
    } = effortRaw;

    if (!activity || !start_date) {
      return;
    }

    const { id = null } = activity;
    const activityId = Number(id);
    if (
      !activityId
      || Number.isNaN(activityId)
      || activityId < MIN_ACTIVITY_ID
    ) {
      return;
    }

    // Create activity if not exists
    if (!this.activities[activityId]) {
      const activityData = this.formatActivity(effortRaw);
      if (activityData) {
        this.activities[activityId] = activityData;
      } else {
        return;
      }
    }

    // Create and add SegmentEffort to activity
    const prevNumSegmentEfforts = this.activities[activityId]
      .segment_efforts
      .length;
    this.addSegmentEffortToActivity(activityId, effortRaw);
    const newNumSegmentEfforts = this.activities[activityId]
      .segment_efforts
      .length;

    // Dedupe and hopefully increment activity's laps
    if (newNumSegmentEfforts > prevNumSegmentEfforts) {
      // This should always be 1
      const delta = newNumSegmentEfforts - prevNumSegmentEfforts;
      this.activities[activityId].laps += delta;
    }
  }
/**
   * Increment activities and stats from a segment effort
   */
Increment activities and stats from a segment effort
Increment activities and stats from a segment effort
processEffort(effortRaw) {
    const {
      activity = false,
      start_date = false,
    } = effortRaw;
    if (!activity || !start_date) {
      return;
    }
    const { id = null } = activity;
    const activityId = Number(id);
    if (
      !activityId
      || Number.isNaN(activityId)
      || activityId < MIN_ACTIVITY_ID
    ) {
      return;
    }
    if (!this.activities[activityId]) {
      const activityData = this.formatActivity(effortRaw);
      if (activityData) {
        this.activities[activityId] = activityData;
      } else {
        return;
      }
    }
    const prevNumSegmentEfforts = this.activities[activityId]
      .segment_efforts
      .length;
    this.addSegmentEffortToActivity(activityId, effortRaw);
    const newNumSegmentEfforts = this.activities[activityId]
      .segment_efforts
      .length;
    if (newNumSegmentEfforts > prevNumSegmentEfforts) {
      const delta = newNumSegmentEfforts - prevNumSegmentEfforts;
      this.activities[activityId].laps += delta;
    }
  }
processEffort ( effortRaw ) { const { activity = false , start_date = false , } = effortRaw ; if ( ! activity || ! start_date ) { return ; } const { id = null } = activity ; const activityId = Number ( id ) ; if ( ! activityId || Number . isNaN ( activityId ) || activityId < MIN_ACTIVITY_ID ) { return ; } if ( ! this . activities [ activityId ] ) { const activityData = this . formatActivity ( effortRaw ) ; if ( activityData ) { this . activities [ activityId ] = activityData ; } else { return ; } } const prevNumSegmentEfforts = this . activities [ activityId ] . segment_efforts . length ; this . addSegmentEffortToActivity ( activityId , effortRaw ) ; const newNumSegmentEfforts = this . activities [ activityId ] . segment_efforts . length ; if ( newNumSegmentEfforts > prevNumSegmentEfforts ) { const delta = newNumSegmentEfforts - prevNumSegmentEfforts ; this . activities [ activityId ] . laps += delta ; } }
Increment activities and stats from a segment effort
Increment activities and stats from a segment effort
// Create activity if not exists // Create and add SegmentEffort to activity // Dedupe and hopefully increment activity's laps // This should always be 1