From cf5dffba49a65058c3ce71d6265e5ec666f34793 Mon Sep 17 00:00:00 2001 From: Brylie Christopher Oxley Date: Wed, 6 Dec 2017 21:06:47 +0200 Subject: [PATCH] Merge for 0.10.1 hotfix (#206) * Meteor update * Remove style that was breaking deployment * meteor update all packages * meteor update all packages * Count number of resident activities on date * Add activityDate field index * Add residentIds field index * Subtract 6 days instead of 7 (from current day) (#205) --- server/methods/homes.js | 17 ++++++++--------- server/methods/residentActivities.js | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/server/methods/homes.js b/server/methods/homes.js index 02c6778a6..23c5c3873 100644 --- a/server/methods/homes.js +++ b/server/methods/homes.js @@ -168,20 +168,19 @@ Meteor.methods({ // Get home residents var residentIds = Meteor.call("getHomeCurrentAndActiveResidentIds",homeId); - // Number of days to look back - var numberOfDays = 7; - // Placeholder array for daily activity level counts var activityCountsArray = []; - for (var i = 0; i < numberOfDays; i++) { - // Get date N days ago for daily activity counts and query - var day = moment().startOf("day").subtract(i, "days"); - var queryDate = moment().endOf("day").subtract(i, "days"); + // Date one week ago (six days, since today counts as one day) + const startDate = moment().subtract(6, 'days'); + + // Get a date object for the end of day today + const endDate = moment().endOf('day'); + for (let currentDay = moment(startDate); currentDay.isBefore(endDate); currentDay.add(1, 'day')) { // Set up placeholder activity counts object var dailyActivityCounts = { - date: day.toDate(), + date: currentDay.toDate(), inactive: 0, semiActive: 0, active: 0 @@ -193,7 +192,7 @@ Meteor.methods({ var result = Meteor.call( "getResidentRecentActiveDaysCount", residentId, - queryDate.toDate() + currentDay.toDate() ); if (result === 0) { diff --git a/server/methods/residentActivities.js b/server/methods/residentActivities.js index c82405b29..08882f459 100644 --- a/server/methods/residentActivities.js +++ b/server/methods/residentActivities.js @@ -32,8 +32,8 @@ Meteor.methods({ // Initialize counter for resident active days let activeDaysCount = 0; - // Date one week ago - const startDate = moment(date).subtract(1, 'weeks'); + // Date one week ago (six days, since today counts as one day) + const startDate = moment(date).subtract(6, 'days'); // Get a date object for the end of day today const endDate = moment(date).endOf('day');