Skip to content

Commit

Permalink
Consistently use integer unix timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
csaudiodesign committed Aug 24, 2023
1 parent d7a08f3 commit dbc63de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/uploader_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ def setupDb(self):
battery text,
temperature text,
rec_end_status text,
indexed_at timestamp,
checked_at timestamp,
meta_uploaded_at timestamp,
file_uploaded_at timestamp,
indexed_at integer default (strftime('%s', 'now')),
checked_at integer,
meta_uploaded_at integer,
file_uploaded_at integer,
root_id integer not null
)''')
c.execute('create index if not exists files_state_idx on files (state)')
Expand All @@ -467,8 +467,8 @@ def setupDb(self):
uuid text unique NOT NULL,
prefix text NOT NULL,
label text,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp
created_at integer default (strftime('%s', 'now')),
updated_at integer default (strftime('%s', 'now'))
)''')
self.database.commit()
c.close()
Expand Down
4 changes: 2 additions & 2 deletions src/uploader_app_meta_th.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def meta_worker(row):
info['filter'] = 'NO_FILTER'

timestamp = datetime.strptime(ts, "%H:%M:%S %d/%m/%Y")
info['timestamp'] = timestamp.replace(tzinfo=timezone(timedelta(hours=hrs, minutes=mins)))
info['timestamp'] = timestamp.replace(tzinfo=timezone(timedelta(hours=hrs, minutes=mins))).timestamp()

amp_res = re.search(r'Amplitude threshold was ([^ ]+) with ([^ ]+)s minimum trigger duration\.', comment)
if amp_res != None:
Expand Down Expand Up @@ -125,7 +125,7 @@ def meta_worker(row):
# infer node name from path
m = re.match(r'.*(\d{4}-\d{4}).+', path)
if m == None:
raise Exception('Node label extraction failed', info['timestamp'].strftime('%Y.%m.%d %H:%M:%S'), info['serial_number'])
raise Exception('Node label extraction failed', info['sha256'], datetime.utcfromtimestamp(info['timestamp']).isoformat() + 'Z', info['serial_number'])
info['node_label'] = m.groups()[0]

except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion src/uploader_app_upload_th.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def get_tasks(self):
if record_raw:
# transform record_raw to dictionary with colname: value
record = {k: record_raw[i] for (i,k) in enumerate(COLS)}

record['timestamp'] = datetime.utcfromtimestamp(record['timestamp']).isoformat() + 'Z'
# check if file is readable. if not, wait
# try:
# is_readable_file(record['path'])
Expand Down

0 comments on commit dbc63de

Please sign in to comment.