Skip to content

Commit

Permalink
Merge pull request #119 from hubmapconsortium/kburke/lockOnUTC
Browse files Browse the repository at this point in the history
Assure UTC time stored in MySQL by using an aware object
  • Loading branch information
yuanzhou authored Jan 18, 2023
2 parents 2e1eae4 + 4f4b1d7 commit e9e08d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ cd hubmap-docker

### Updating API Documentation

The documentation for the API calls is hosted on SmartAPI. Modifying the `files-api-spec.yaml` file and commititng the changes to github should update the API shown on SmartAPI. SmartAPI allows users to register API documents. The documentation is associated with this github account: [email protected].
The documentation for the API calls is hosted on SmartAPI. Modifying the `uuid-api-spec.yaml` file and committing the changes to GitHub should update the API shown on SmartAPI. SmartAPI allows users to register API documents. The documentation is associated with this GitHub account: [email protected].
7 changes: 5 additions & 2 deletions src/uuid_worker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime, timezone
import logging

import mysql.connector.errors
Expand Down Expand Up @@ -611,7 +612,9 @@ def newUUIDs(self, parentIDs, entityType, userId, userEmail, nIds, organ_code=No
# if entityType == 'DONOR':
gen_base_ids = entityType in ID_ENTITY_TYPES
returnIds = []
now = time.strftime('%Y-%m-%d %H:%M:%S')
# See admonition at https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow to
# retrieve a non-naive UTC time.
awareUTCTimeNow = datetime.now(timezone.utc)
store_file_info = False
if entityType == 'FILE':
store_file_info = True
Expand Down Expand Up @@ -673,7 +676,7 @@ def newUUIDs(self, parentIDs, entityType, userId, userEmail, nIds, organ_code=No
# insRow = (insUuid, ins_app_base_id, entityType, now, userId, userEmail)

# Only set the attributes tuple of committing attributes to the table besides the UUID
insertVals.append((insUuid, entityType, now, userId, userEmail))
insertVals.append((insUuid, entityType, awareUTCTimeNow, userId, userEmail))
if insert_attributes_for_uuid:
insertAttribVals.append((insUuid, ins_app_base_id, submission_ids[n] if gen_submission_ids else None))

Expand Down

0 comments on commit e9e08d4

Please sign in to comment.