[fix] update data if changed on the same day
This commit is contained in:
parent
cdf103af68
commit
82814ab58e
|
@ -15,19 +15,23 @@ def main(host='localhost', port=8086, user='root', password='root', dbname='demo
|
||||||
|
|
||||||
points = lastentry.get_points('steps')
|
points = lastentry.get_points('steps')
|
||||||
lastdate = list(points)[0]['time']
|
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())
|
ts = time.mktime(datetime.datetime.strptime(lastdate, '%Y-%m-%dT%H:%M:%SZ').timetuple())
|
||||||
else:
|
else:
|
||||||
ts=0
|
ts=0
|
||||||
lastdate=0
|
lastdate=0
|
||||||
|
laststeps=0
|
||||||
|
|
||||||
if args.verbose:
|
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)
|
con = lite.connect(dbfile)
|
||||||
with con:
|
with con:
|
||||||
|
|
||||||
cur = con.cursor()
|
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:
|
while True:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue