Compare commits
2 Commits
6619841363
...
4ffb56328f
Author | SHA1 | Date |
---|---|---|
n | 4ffb56328f | |
n | 64bfd5b9d3 |
|
@ -10,7 +10,6 @@ from influxdb import InfluxDBClient
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
"""Instantiate the connection to the InfluxDB client."""
|
"""Instantiate the connection to the InfluxDB client."""
|
||||||
|
|
||||||
influx_db = InfluxDBClient(args.host, args.port, args.user, args.password, args.dbname)
|
influx_db = InfluxDBClient(args.host, args.port, args.user, args.password, args.dbname)
|
||||||
measurementime_stamp = influx_db.get_list_measurementime_stamp()
|
measurementime_stamp = influx_db.get_list_measurementime_stamp()
|
||||||
time_stamp = 0
|
time_stamp = 0
|
||||||
|
@ -18,11 +17,11 @@ def main(args):
|
||||||
lastime_stampteps = 0
|
lastime_stampteps = 0
|
||||||
if measurementime_stamp != []:
|
if measurementime_stamp != []:
|
||||||
lastentry = influx_db.query('SELECT LAST("steps") FROM "steps"')
|
lastentry = influx_db.query('SELECT LAST("steps") FROM "steps"')
|
||||||
|
|
||||||
pointime_stamp = lastentry.get_pointime_stamp('steps')
|
pointime_stamp = lastentry.get_pointime_stamp('steps')
|
||||||
lastdate = list(pointime_stamp)[0]['time']
|
lastdate = list(pointime_stamp)[0]['time']
|
||||||
time_stamp = time.mktime(datetime.datetime.strptime(lastdate, '%Y-%m-%dT%H:%M:%SZ')
|
time_stamp = time.mktime(datetime.datetime.strptime(lastdate, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
.timetuple())
|
.timetuple())
|
||||||
|
|
||||||
if time_stamp == datetime.datetime.now().timestamp() // 86400 * 86400 + time.timezone:
|
if time_stamp == datetime.datetime.now().timestamp() // 86400 * 86400 + time.timezone:
|
||||||
pointime_stamp = lastentry.get_pointime_stamp('steps')
|
pointime_stamp = lastentry.get_pointime_stamp('steps')
|
||||||
lastime_stampteps = list(pointime_stamp)[0]['last']
|
lastime_stampteps = list(pointime_stamp)[0]['last']
|
||||||
|
@ -33,14 +32,11 @@ def main(args):
|
||||||
|
|
||||||
con = lite.connect(args.dbfile)
|
con = lite.connect(args.dbfile)
|
||||||
with con:
|
with con:
|
||||||
|
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
cur.execute(f'SELECT recordedForDate,steps,distanceInMeters,activeTimeInSeconds,calories \
|
cur.execute(f'SELECT recordedForDate,steps,distanceInMeters,activeTimeInSeconds,calories \
|
||||||
FROM dailyActivityLog \
|
FROM dailyActivityLog \
|
||||||
WHERE recordedForDate >= {time_stamp} AND steps > {lastime_stampteps}')
|
WHERE recordedForDate >= {time_stamp} AND steps > {lastime_stampteps}')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
if row is None:
|
if row is None:
|
||||||
break
|
break
|
||||||
|
@ -54,10 +50,8 @@ def main(args):
|
||||||
"calories":row[4]
|
"calories":row[4]
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
print(f'writing data for {mytime}')
|
print(f'writing data for {mytime}')
|
||||||
|
|
||||||
influx_db.write_pointime_stamp(data)
|
influx_db.write_pointime_stamp(data)
|
||||||
influx_db.close()
|
influx_db.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue