Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timestamp to correct format #248

Merged
merged 7 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tube/etl/outputs/es/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def check_to_run_etl(es, index_names):


def timestamp_from_transaction_time(dt):
return "time_{trans_time}".format(trans_time=dt.strftime("%Y-%m-%dT%H-%M-%S"))
return "time_{trans_time}".format(trans_time=dt.strftime("%Y%m%dT%H%M%SZ"))


def get_timestamp_from_index(es, versioned_index):
res = es.indices.get_alias(index=versioned_index, name="time_*")
iso_str = list(res[versioned_index]["aliases"].keys())[0].replace("plus", "+")[5:]
return datetime.strptime(iso_str, "%Y-%m-%dT%H:%M:%S")
return datetime.strptime(iso_str, "%Y%m%dT%H%M%SZ")


def putting_timestamp(es, index_to_write):
Expand Down
15 changes: 9 additions & 6 deletions tube/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
# and setup $XDG_DATA_HOME/.local/share/gen3/tube/creds.json
#
conf_data = load_json("creds.json", "tube")
DB_HOST = conf_data.get("db_host", "localhost")
DB_PORT = conf_data.get("db_port", "5432")
DB_DATABASE = conf_data.get("db_database", "gdcdb")
DB_USERNAME = conf_data.get("db_username", "peregrine")
DB_PASSWORD = conf_data.get("db_password", "unknown")
DB_USE_SSL = conf_data.get("db_use_ssl", False) # optional property to db_use_ssl
DB_HOST = os.getenv("DB_HOST") or conf_data.get("db_host", "localhost")
DB_PORT = os.getenv("DB_PORT") or conf_data.get("db_port", "5432")
DB_DATABASE = os.getenv("DB_DATABASE") or conf_data.get("db_database", "sheepdog")
DB_USERNAME = os.getenv("DB_USERNAME") or conf_data.get("db_username", "peregrine")
DB_PASSWORD = os.getenv("DB_PASSWORD") or conf_data.get("db_password", "unknown")

DB_USE_SSL = os.getenv("DB_USE_SSL") or conf_data.get(
"db_use_ssl", False
) # optional property to db_use_ssl
JDBC = (
"jdbc:postgresql://{}:{}/{}".format(DB_HOST, DB_PORT, DB_DATABASE)
if DB_USE_SSL is False
Expand Down
Loading