Update insert_event.py.

This script now works with the new event log.

Fixes #234. Midnight positions can be added via a cronjob such
as:

$DOUGAL_ROOT/BIN/insert_event.py -t "$(date -I) 00:00:00Z" \
    -l Daily -l Prod \
    "Midnight position: @DMS@ (@POS@)"
This commit is contained in:
D. Berge
2022-05-12 22:15:09 +02:00
parent d6b985fcd2
commit bb5de9a00e

View File

@@ -38,11 +38,11 @@ if __name__ == '__main__':
message = " ".join(args["remarks"]) message = " ".join(args["remarks"])
print("new event:", schema, tstamp, message) print("new event:", schema, tstamp, message, args["label"])
if schema and tstamp and message: if schema and tstamp and message:
db.set_survey(schema) db.set_survey(schema)
with db.conn.cursor() as cursor: with db.conn.cursor() as cursor:
qry = "INSERT INTO events_timed (tstamp, remarks) VALUES (%s, %s);" qry = "INSERT INTO event_log (tstamp, remarks, labels) VALUES (%s, replace_placeholders(%s, %s, NULL, NULL), %s);"
cursor.execute(qry, (tstamp, message)) cursor.execute(qry, (tstamp, message, tstamp, args["label"]))
db.maybe_commit() db.maybe_commit()