forked from ktdemay/GymBuddy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActivityTracker.js
47 lines (40 loc) · 951 Bytes
/
ActivityTracker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function calculateMinutes()
{
var date = new Date();
var minute = (date.getHours() * 60) + date.getMinutes();
return minute;
}
function addPerson(map, minutes, currentAttendance, closingTime)
{
//Random integer between 45 and 60
var duration = Math.floor(Math.random() * 30) + 45;
var departTime = Math.min(seconds + duration, closingTime);
if(minutes >= closingTime)
{
return currentAttendance;
}
if(map.has(departTime))
{
map.set(departTime, map.get(departTime) + 1);
}
else
{
map.set(departTime, 1);
}
return currentAttendance += 1;
}
function removePeople(map, minutes, currentAttendance)
{
if(map.has(minutes))
{
currentAttendance -= map.get(minutes);
map.remove(minutes);
}
return currentAttendance;
}
function poll(map, currentAttendance)
{
var minutes = calculateMinutes();
currentAttendance = removePeople(map, minutes, currentAttendance);
return currentAttendance;
}