Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update UI #56

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 5 additions & 46 deletions src/Sleep.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
class Sleep {
constructor(sleepData, userNow, date, userRepo) {
// constructor(sleepData, userNow, userRepo) {
this.sleepData = sleepData;
this.user = userNow;
this.date = date;
// this.date = this.returnToday(this.sleepData);
this.userRepo = userRepo;
}

Expand Down Expand Up @@ -35,13 +33,11 @@ class Sleep {
});
return findSleepQualityByDate.sleepQuality;
}

calculateWeekSleep() {
return this.userRepo.getWeekFromDate(this.date, this.user.id, this.sleepData).map((data) => `${data.date}: ${data.hoursSlept}`);
}

calculateWeekSleepQuality() {
return this.userRepo.getWeekFromDate(this.date, this.user.id, this.sleepData).map((data) => `${data.date}: ${data.sleepQuality}`);

userDataForWeek(relevantData) {
return this.userRepo.getWeekFromDate(this.date, this.user.id, this.sleepData).map((data) => {
return {x: data.date, y: data[relevantData]}
});
}

calculateAllUserSleepQuality() {
Expand All @@ -52,44 +48,7 @@ class Sleep {
let total = totalSleepQuality / this.sleepData.length;
return parseFloat(total.toFixed(2));
}
// determineBestSleepers(date, userRepo) {
// let timeline = userRepo.chooseWeekDataForAllUsers(this.sleepData, date);
// let userSleepObject = userRepo.isolateUsernameAndRelevantData(this.sleepData, date, 'sleepQuality', timeline);

// return Object.keys(userSleepObject).filter(function(key) {
// return (userSleepObject[key].reduce(function(sumSoFar, sleepQualityValue) {
// sumSoFar += sleepQualityValue
// return sumSoFar;
// }, 0) / userSleepObject[key].length) > 3
// }).map(function(sleeper) {
// return userRepo.getDataFromID(parseInt(sleeper)).name;
// })
// }
// determineSleepWinnerForWeek(date, userRepo) {
// let timeline = userRepo.chooseWeekDataForAllUsers(this.sleepData, date);
// let sleepRankWithData = userRepo.combineRankedUserIDsAndAveragedData(this.sleepData, date, 'sleepQuality', timeline);

// return this.getWinnerNamesFromList(sleepRankWithData, userRepo);
// }
// determineSleepHoursWinnerForDay(date, userRepo) {
// let timeline = userRepo.chooseDayDataForAllUsers(this.sleepData, date);
// let sleepRankWithData = userRepo.combineRankedUserIDsAndAveragedData(this.sleepData, date, 'hoursSlept', timeline);

// return this.getWinnerNamesFromList(sleepRankWithData, userRepo);
// }
// getWinnerNamesFromList(sortedArray, userRepo) {
// let bestSleepers = sortedArray.filter(function(element) {
// return element[Object.keys(element)] === Object.values(sortedArray[0])[0]
// });

// let bestSleeperIds = bestSleepers.map(function(bestSleeper) {
// return (Object.keys(bestSleeper));
// });

// return bestSleeperIds.map(function(sleepNumber) {
// return userRepo.getDataFromID(parseInt(sleepNumber)).name;
// });
// }
}


Expand Down
Loading