database_interface module

database_interface.add_hr(email, heart_rate)

Updates existing user by adding new heart rate measurement and timestamp of measurement

Parameters:
  • email – user email as string type which serves as user id
  • heart_rate – one heart rate measurement as integer type
Returns:

adds new heart rate measurement and timestamp of measurement to mongo database

database_interface.calc_avg_for_interval(email, time_since)

Calculates average heart rate after a certain timestamp

Parameters:
  • email – user email as string type which serves as user id
  • time_since – timestamp as string type in the format YYYY-MM-DD HH:MM:SS.ssssss
Returns:

average heart rate after the input timestamp

database_interface.check_tachy(email, avg_hr)

Checks if a heart rate is tachycardic based on user’s age

Parameters:
  • email – user email as string type which serves as user id
  • avg_hr – one heart rate measurement as integer type
Returns:

True if heart rate is tachycardic, otherwise False

database_interface.check_user_exists(email)

Check if a user exists in the mongo database by searching for their email

Parameters:email – user email as string type which serves as user id
Returns:True if user exists, False if user does not exist
database_interface.create_user(email, age, heart_rate)

Creates new user in mongo database with new heart rate measurement and timestamp

Parameters:
  • email – user email as string type which serves as user id
  • age – user age as integer type
  • heart_rate – one heart rate measurement as integer type
Returns:

adds new user with age, heart rate measurement, and timestamp of measurement to mongo database

database_interface.get_hr_and_times(email)

Gets all heart rates and timestamps for a user

Parameters:email – user email as string type which serves as user id
Returns:list of heart rates, list of timestamps, and age of user
database_interface.update_user(email, age, heart_rate)

Updates user by detecting if user exists and either creating new user or updating existing user

Parameters:
  • email – user email as string type which serves as user id
  • age – user age as integer type
  • heart_rate – one heart rate measurement as integer type
Returns:

updates user information in mongo database