hfaerber/Refactor-tractor-Fit-lit

Refactor methods to returnAverageActivityForWeek

Closed this issue · 3 comments

Activity
Line 55, 64, 73

We can refactor these 3 methods into 1 that takes 'metric' as a parameter in addition to the week.

Currently these are build to accept a number (like 1) for the week. We might need to look at these. Do we want them to be able to accept a specific date?

These 3 methods have been refactored into one dynamic method that takes an argument of 'metric'. No changes have been made to the way this method accepts the 'week' argument so it still cannot accept a specific date. Possible enhancement?

This is how things look presently in our Utility class. I'll keep this open for further review and discussion.

returnAvgUserStatForWeek(week, metric) {
    let weekOfData = this.returnWeekOfStatsForUser(week, this.singleUserData);
    return Math.floor(weekOfData.reduce((totalMetric, eachDay) => {
      totalMetric += eachDay[metric]; 
      return totalMetric
    }, 0) / 7)
  }

I'm closing this issue since it is fully functional as-is. We can always reopen as an enhancement opportunity if we have time.