現在の日付のアイテムが既にあるかどうかを確認しようとしています。ない場合は追加します。以下のコードはエラーを表示していませんが、MongoDB に何も保存していません。
if len(site.DaylyLog) != 0:
print len(site.DaylyLog)
print site.DaylyLog[-1]
current_date_daylylog = site.DaylyLog[-1]['aggregate_date']
else:
current_date_daylylog = ''
if current_date_daylylog == datetime.date.today():
#update document
print current_date_daylylog
print "calculating averages"
site.DaylyLog[-1].average_response_time = (site.DaylyLog[-1].average_response_time+record_uptime.response_time)/2
site.DaylyLog[-1].average_uptime = (site.DaylyLog[-1].average_uptime+100)/2
site.save()
else:
print current_date_daylylog
print "adding new uptime"
print site.url
aggregate_uptime = AggregatedUptime()
aggregate_uptime.average_response_time = record_uptime.response_time
aggregate_uptime.average_uptime = 100
aggregate_uptime.total_downtime = 0
aggregate_uptime.aggregate_date = datetime.date.today()
print aggregate_uptime.aggregate_date
print aggregate_uptime.average_response_time
site.DaylyLog.append(aggregate_uptime)
site.save()
print site.DaylyLog[-1].aggregate_date