Skip to content

Commit

Permalink
Final try to convert str to date for populating analysis_runner table.
Browse files Browse the repository at this point in the history
  • Loading branch information
milo-hyben committed Apr 4, 2024
1 parent 4855f13 commit ce33524
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion db/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,12 @@
hail_version, batch_url, submitting_user, meta, audit_log_id ) SELECT
COALESCE(JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.ar-guid')), UUID()) as ar_guid,
analysis.project as project,
CONVERT(JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.timestamp')), DATETIME) as timestamp,
STR_TO_DATE(SUBSTRING_INDEX(JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.timestamp')), '.', 1), '%Y-%m-%dT%H:%i:%s') -- date portion
+ INTERVAL (
60 * SUBSTRING(JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.timestamp')), LENGTH(JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.timestamp'))) - 4, 2) -- hours offset
+ SUBSTRING(JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.timestamp')), LENGTH(JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.timestamp'))) - 1, 2) -- minutes offset
) * (CASE WHEN JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.timestamp')) LIKE '%+%' THEN 1 ELSE -1 END) MINUTE-- +/- offset
as timestamp,
JSON_UNQUOTE(JSON_EXTRACT(analysis.meta,
'$.accessLevel')) as access_level, JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.repo'))
as repository, JSON_UNQUOTE(JSON_EXTRACT(analysis.meta, '$.commit')) as `commit`,
Expand Down

0 comments on commit ce33524

Please sign in to comment.