Compare commits

..

2 Commits

Author SHA1 Message Date
n 6619841363
add Gitea CI
lint / lint (push) Successful in 31s Details
2024-02-13 22:33:20 +01:00
n 7f21244c01
pylint fixes 2024-02-13 22:33:20 +01:00
1 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,7 @@ 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()
time_stamp = 0
@ -17,11 +18,11 @@ def main(args):
lastime_stampteps = 0
if measurementime_stamp != []:
lastentry = influx_db.query('SELECT LAST("steps") FROM "steps"')
pointime_stamp = lastentry.get_pointime_stamp('steps')
lastdate = list(pointime_stamp)[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']
@ -32,11 +33,14 @@ def main(args):
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}')
while True:
row = cur.fetchone()
if row is None:
break
@ -50,8 +54,10 @@ def main(args):
"calories":row[4]
}
}]
if args.verbose:
print(f'writing data for {mytime}')
influx_db.write_pointime_stamp(data)
influx_db.close()