from recover.models import *
from recover.patient_data import *
from datetime import date

def midnightRun():
    physicians = User.objects()
    for physician in physicians:
        patients = physician.patients
        for patient in patients:
            data = PatientData(patient)
            last_synced = patient.date_last_synced.isoformat()
            last_synced = last_synced[0:10]
            data.get_heart_rate_data_for_date_range(last_synced)
            data.get_activity_data_for_date_range(last_synced)

from recover.models import *
from recover.patient_data import *
import datetime


def midnightRun():
    physicians = User.objects()
    for physician in physicians:
        patients = physician.patients
        for patient in patients:
            data = PatientData(patient)
            last_synced = patient.date_last_synced.isoformat()
            last_synced = last_synced[0:10]
            data.get_heart_rate_data_for_date_range(last_synced)
            data.get_activity_data_for_date_range(last_synced)
            patient.date_last_synced = datetime.datetime.now()

Update 'date_last_synced' field on each patient after midnight fetching
Update 'date_last_synced' field on each patient after midnight fetching

  from recover.models import *
  from recover.patient_data import *
- from datetime import date
+ import datetime
+ 
  
  def midnightRun():
      physicians = User.objects()
      for physician in physicians:
          patients = physician.patients
          for patient in patients:
              data = PatientData(patient)
              last_synced = patient.date_last_synced.isoformat()
              last_synced = last_synced[0:10]
              data.get_heart_rate_data_for_date_range(last_synced)
              data.get_activity_data_for_date_range(last_synced)
+             patient.date_last_synced = datetime.datetime.now()
  
Update 'date_last_synced' field on each patient after midnight fetching
## Code Before:
from recover.models import *
from recover.patient_data import *
from datetime import date

def midnightRun():
    physicians = User.objects()
    for physician in physicians:
        patients = physician.patients
        for patient in patients:
            data = PatientData(patient)
            last_synced = patient.date_last_synced.isoformat()
            last_synced = last_synced[0:10]
            data.get_heart_rate_data_for_date_range(last_synced)
            data.get_activity_data_for_date_range(last_synced)

## Instruction:
Update 'date_last_synced' field on each patient after midnight fetching
## Code After:
from recover.models import *
from recover.patient_data import *
import datetime


def midnightRun():
    physicians = User.objects()
    for physician in physicians:
        patients = physician.patients
        for patient in patients:
            data = PatientData(patient)
            last_synced = patient.date_last_synced.isoformat()
            last_synced = last_synced[0:10]
            data.get_heart_rate_data_for_date_range(last_synced)
            data.get_activity_data_for_date_range(last_synced)
            patient.date_last_synced = datetime.datetime.now()
