Compare commits
3 commits
54c2948017
...
44d7bd9159
Author | SHA1 | Date | |
---|---|---|---|
44d7bd9159 | |||
9f19b7d326 | |||
aa16c1f792 |
1 changed files with 11 additions and 11 deletions
|
@ -11,31 +11,31 @@ from influxdb import InfluxDBClient
|
|||
def main(args):
|
||||
"""Instantiate the connection to the InfluxDB client."""
|
||||
influx_db = InfluxDBClient(args.host, args.port, args.user, args.password, args.dbname)
|
||||
measurementime_stamp = influx_db.get_list_measurementime_stamp()
|
||||
measurements = influx_db.get_list_measurements()
|
||||
time_stamp = 0
|
||||
lastdate = 0
|
||||
lastime_stampteps = 0
|
||||
if measurementime_stamp != []:
|
||||
laststeps = 0
|
||||
if measurements != []:
|
||||
lastentry = influx_db.query('SELECT LAST("steps") FROM "steps"')
|
||||
pointime_stamp = lastentry.get_pointime_stamp('steps')
|
||||
lastdate = list(pointime_stamp)[0]['time']
|
||||
points = lastentry.get_points('steps')
|
||||
lastdate = list(points)[0]['time']
|
||||
time_stamp = time.mktime(datetime.datetime.strptime(lastdate, '%Y-%m-%dT%H:%M:%SZ')
|
||||
.timetuple())
|
||||
|
||||
if time_stamp == datetime.datetime.now().timestamp() // 86400 * 86400 + time.timezone:
|
||||
pointime_stamp = lastentry.get_pointime_stamp('steps')
|
||||
lastime_stampteps = list(pointime_stamp)[0]['last']
|
||||
points = lastentry.get_points('steps')
|
||||
laststeps = list(points)[0]['last']
|
||||
|
||||
if args.verbose:
|
||||
print(f'last entry is {lastdate}, time_stamp is {time_stamp}, \
|
||||
number of steps is {lastime_stampteps}\n')
|
||||
print(f'last entry is {lastdate}, timestamp is {time_stamp}, \
|
||||
number of steps is {laststeps}\n')
|
||||
|
||||
con = lite.connect(args.dbfile)
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cur.execute(f'SELECT recordedForDate,steps,distanceInMeters,activeTimeInSeconds,calories \
|
||||
FROM dailyActivityLog \
|
||||
WHERE recordedForDate >= {time_stamp} AND steps > {lastime_stampteps}')
|
||||
WHERE recordedForDate >= {time_stamp} AND steps > {laststeps}')
|
||||
while True:
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
|
@ -52,7 +52,7 @@ def main(args):
|
|||
}]
|
||||
if args.verbose:
|
||||
print(f'writing data for {mytime}')
|
||||
influx_db.write_pointime_stamp(data)
|
||||
influx_db.write_points(data)
|
||||
influx_db.close()
|
||||
|
||||
def parse_args():
|
||||
|
|
Loading…
Reference in a new issue