async function doCommand({
  subargs,
  dryRun: isDryRun = false,
}) {
  if (!checkNumArgs(subargs, 2, '<athleteId> <activityId> [--dry-run]')) {
    return;
  }
  const activityDoc = await Activity.findOne({
    athlete_id: subargs[0],
    _id: subargs[1],
  });
  if (!activityDoc) {
    console.log(`Could not find Activity ${subargs[1]} for Athlete ${subargs[0]}`);
    return;
  }
  if (isDryRun) {
    console.log(DRY_RUN_MSG);
  }
  summarizeActivity(activityDoc);
  console.log('BEFORE');
  const prevAthleteDoc = await Athlete.findById(subargs[0]).lean();
  if (prevAthleteDoc) {
    summarizeStats(
      prevAthleteDoc.stats,
      activityDoc.location,
      parseInt(activityDoc.start_date_local, 10), // year
    );
  }

  const nextAthleteDoc = await deleteActivityFromAthleteStats(
    activityDoc,
    isDryRun,
  );

  // eslint-disable-next-line
  console.log(`${"\n"}AFTER`);
  summarizeStats(
    nextAthleteDoc.stats,
    activityDoc.location,
    parseInt(activityDoc.start_date_local, 10), // year
  );
  if (isDryRun) {
    console.log(DRY_RUN_MSG);
  }
}
/**
 * Delete a single activity from activities collection and decrement athlete's stats
 */
Delete a single activity from activities collection and decrement athlete's stats
Delete a single activity from activities collection and decrement athlete ' s stats
async function doCommand({
  subargs,
  dryRun: isDryRun = false,
}) {
  if (!checkNumArgs(subargs, 2, '<athleteId> <activityId> [--dry-run]')) {
    return;
  }
  const activityDoc = await Activity.findOne({
    athlete_id: subargs[0],
    _id: subargs[1],
  });
  if (!activityDoc) {
    console.log(`Could not find Activity ${subargs[1]} for Athlete ${subargs[0]}`);
    return;
  }
  if (isDryRun) {
    console.log(DRY_RUN_MSG);
  }
  summarizeActivity(activityDoc);
  console.log('BEFORE');
  const prevAthleteDoc = await Athlete.findById(subargs[0]).lean();
  if (prevAthleteDoc) {
    summarizeStats(
      prevAthleteDoc.stats,
      activityDoc.location,
      parseInt(activityDoc.start_date_local, 10), 
    );
  }
  const nextAthleteDoc = await deleteActivityFromAthleteStats(
    activityDoc,
    isDryRun,
  );
  console.log(`${"\n"}AFTER`);
  summarizeStats(
    nextAthleteDoc.stats,
    activityDoc.location,
    parseInt(activityDoc.start_date_local, 10), 
  );
  if (isDryRun) {
    console.log(DRY_RUN_MSG);
  }
}
async function doCommand ( { subargs , dryRun : isDryRun = false , } ) { if ( ! checkNumArgs ( subargs , 2 , '<athleteId> <activityId> [--dry-run]' ) ) { return ; } const activityDoc = await Activity . findOne ( { athlete_id : subargs [ 0 ] , _id : subargs [ 1 ] , } ) ; if ( ! activityDoc ) { console . log ( ` ${ subargs [ 1 ] } ${ subargs [ 0 ] } ` ) ; return ; } if ( isDryRun ) { console . log ( DRY_RUN_MSG ) ; } summarizeActivity ( activityDoc ) ; console . log ( 'BEFORE' ) ; const prevAthleteDoc = await Athlete . findById ( subargs [ 0 ] ) . lean ( ) ; if ( prevAthleteDoc ) { summarizeStats ( prevAthleteDoc . stats , activityDoc . location , parseInt ( activityDoc . start_date_local , 10 ) , ) ; } const nextAthleteDoc = await deleteActivityFromAthleteStats ( activityDoc , isDryRun , ) ; console . log ( ` ${ "\n" } ` ) ; summarizeStats ( nextAthleteDoc . stats , activityDoc . location , parseInt ( activityDoc . start_date_local , 10 ) , ) ; if ( isDryRun ) { console . log ( DRY_RUN_MSG ) ; } }
Delete a single activity from activities collection and decrement athlete's stats
Delete a single activity from activities collection and decrement athlete ' s stats
// year // eslint-disable-next-line // year