[fix] update data if changed on the same day

This commit is contained in:
n 2022-02-27 13:07:51 +01:00
parent cdf103af68
commit 82814ab58e
Signed by: n
GPG Key ID: 510227DD6C502CE3
1 changed files with 6 additions and 2 deletions

View File

@ -15,19 +15,23 @@ def main(host='localhost', port=8086, user='root', password='root', dbname='demo
points = lastentry.get_points('steps')
lastdate = list(points)[0]['time']
points = lastentry.get_points('steps')
laststeps = list(points)[0]['last']
ts = time.mktime(datetime.datetime.strptime(lastdate, '%Y-%m-%dT%H:%M:%SZ').timetuple())
else:
ts=0
lastdate=0
laststeps=0
if args.verbose:
print("last entry is %s, ts is %s\n" % (lastdate,ts))
print("last entry is %s, ts is %s, number of steps is %s\n" % (lastdate,ts,laststeps))
con = lite.connect(dbfile)
with con:
cur = con.cursor()
cur.execute("SELECT recordedForDate,steps,distanceInMeters,activeTimeInSeconds,calories FROM dailyActivityLog WHERE recordedForDate > %s" %ts)
cur.execute("SELECT recordedForDate,steps,distanceInMeters,activeTimeInSeconds,calories FROM dailyActivityLog WHERE recordedForDate >= %s AND steps > %s" % (ts,laststeps))
while True: