Skip to content

Commit

Permalink
fix(get-available-diary-slots): remove the logs from prev commit
Browse files Browse the repository at this point in the history
  • Loading branch information
reecebrend committed Oct 11, 2018
1 parent fd3612b commit 64c7e72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ const moment = require('moment')
module.exports = function generateTimeSlots (diary, inputDate) {
const slots = []

console.log('Inside generate-time-slots')

const date = moment(inputDate).format('YYYY-MM-DD')
console.log('Date selected is ', date)
let startTime = moment(date + 'T' + diary.slots.startTime)
console.log('Start time for date is ', startTime)
let endTime = moment(date + 'T' + diary.slots.endTime)
console.log('End time for date is ', startTime)

while (startTime.isBefore(endTime)) {
console.log('Adding slot ', startTime.format('HH:mm:ss'))
slots.push([startTime.format('HH:mm:ss'), 0])
console.log('Adding to start time ', diary.slots.durationMinutes)
startTime.add(diary.slots.durationMinutes, 'm')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ module.exports = class GetAvailableDiarySlots {
const diaryService = this.services.diaries
const diary = diaryService.diaries[namespace + '_' + this.diaryId]

let entries = await this.entryModel.find({ where: { 'diaryId': { equals: this.diaryId } } })
console.log('Getting diary entries for ', this.diaryId)
let entries = await this.entryModel.find({where: {'diaryId': {equals: this.diaryId}}})
entries = entries.filter(booking => moment(event.date).format('YYYY-MM-DD') === moment(booking.startDateTime).format('YYYY-MM-DD'))
console.log('Found these entries: ', entries)

const availableTimes = getAvailableDiarySlots(diary, event.date)
console.log('These are the available time slots (should appear in app)', availableTimes)

const remove = []

Expand All @@ -31,7 +28,9 @@ module.exports = class GetAvailableDiarySlots {
const d = event.date.split('T')[0] + 'T' + timeSlot[0]
if (moment(d).isSame(moment(booking.startDateTime))) {
timeSlot[1]++
if (timeSlot[1] >= diary.slots.maxConcurrency) remove.push(index)
if (timeSlot[1] >= diary.slots.maxConcurrency) {
remove.push(index)
}
}
})

Expand Down

0 comments on commit 64c7e72

Please sign in to comment.