After one month, Sleep Tracker will give recommendation of optimal sleep duration.
## Target Audience
Sleep Tracker is intended for anyone interested in improving their sleep and health.
## Features
- Homepage view shows a graph of your nightly hours of sleep over time .
- Ability to create a night’s sleep entry. For each date set (1/1/19-1/2/19), user can scroll through a digital clock image (like when you set your alarm on your phone, or just type in) to enter what time they got in bed and what time they woke up. From this data, app will calculate their total time in bed.
- Ability to edit or delete a sleep entry.
- Ability to click one of four emoji buttons to rate how they felt right when they woke up, how they felt during the day, and how tired they felt when they went to bed. Behind the scenes, a score 1-4 is given for each emoji.
- The app will calculate an average mood score for 1/2/19, and compare it to the time spent in bed. The app will then recommend after using for >1 month how much sleep you need. “Your mood score tends to be highest when you sleep 7.5 hours”
## Possible further features
- Make recommendations not only based on sleep time, but also on bed time (some reasearch will need to be done in that area)
An array of json objects containing sessions related to the user with the provided `id`.
```
[
{
"id": 1,
"user_id": 1,
"bed_time": "2019-07-05 22:10:25",
"wake_time": "2019-07-06 07:10:25",
"wake_mood": 3,
"day_mood": 3,
"bed_tiredness": 3
},
{
"id": 2,
"user_id": 1,
"bed_time": "2019-07-05 22:10:25",
"wake_time": "2019-07-06 07:10:25",
"wake_mood": 5,
"day_mood": 5,
"bed_tiredness": 5
}
]
```
#### Add a session
**`POST /api/users/sessions`**
##### Request
A json object with **`user_id`**, **`bed_time`**, **`wake_time`** and optionnally `wake_mood`, `day_mood`, `bed_tiredness`.
> NB: **`wake_mood`**, **`day_mood`**, and **`bed_tiredness`** are required for calculating daily average mood and sleep duration, but can be added later by updating the session.
```
{
"user_id": 1,
"bed_time": "2019-07-05 22:10:25",
"wake_time": "2019-07-06 07:10:25",
"wake_mood": 3,
"day_mood": 3,
"bed_tiredness": 3
}
```
##### Response
A json object with the newly created session.
```
{
"id": 1,
"user_id": 1,
"bed_time": "2019-07-05 22:10:25",
"wake_time": "2019-07-06 07:10:25",
"wake_mood": 3,
"day_mood": 3,
"bed_tiredness": 3
}
```
#### Update a session by id
**`PUT /api/users/sessions/:id`**
> Session **id** as params in the URL.
##### Request
A json object with **`user_id`**, **`bed_time`**, **`wake_time`** and optionnally `wake_mood`, `day_mood`, `bed_tiredness`.
```
{
"user_id": 1,
"bed_time": "2019-07-05 22:10:25",
"wake_time": "2019-07-06 07:10:25",
"wake_mood": 5,
"day_mood": 5,
"bed_tiredness": 5
}
```
##### Response
A json object with the updated session with `id`.
```
{
"id": 1,
"user_id": 1,
"bed_time": "2019-07-05 22:10:25",
"wake_time": "2019-07-06 07:10:25",
"wake_mood": 5,
"day_mood": 5,
"bed_tiredness": 5
}
```
#### Delete a session by id
**`DELETE /api/users/sessions/:id`**
> Session **id** as params in the URL.
##### Response
A json object with a confirmation `message`.
```
{
"message": 'The session has been successfully deleted.'