Skip to content

Commit

Permalink
Merge for 0.10.1 hotfix (#206)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
brylie authored Dec 6, 2017
1 parent 16021a0 commit cf5dffb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions server/methods/homes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -193,7 +192,7 @@ Meteor.methods({
var result = Meteor.call(
"getResidentRecentActiveDaysCount",
residentId,
queryDate.toDate()
currentDay.toDate()
);

if (result === 0) {
Expand Down
4 changes: 2 additions & 2 deletions server/methods/residentActivities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit cf5dffb

Please sign in to comment.