Skip to content

Commit

Permalink
Fix timestamp and json config issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jawadqur committed Nov 21, 2023
1 parent 071668f commit b668a9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tube/config_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def load_json(file_name, app_name, search_folders=None):
"""
json.load(file_name) after finding file_name in search_folders
return the loaded json data or None if file not found
return the loaded json data or empty dictionary if file not found
"""
actual_files = find_paths(file_name, app_name, search_folders)
if not actual_files:
return None
return {}
with open(actual_files[0], "r") as reader:
return json.load(reader)
8 changes: 5 additions & 3 deletions tube/etl/outputs/es/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def get_latest_utc_transaction_time():
)
else:
latest_time = query_result_time[2]
return to_utc_time(latest_time)
return to_utc_time(
datetime.strptime(latest_time.strftime("%Y%m%dT%H%M%SZ"), "%Y%m%dT%H%M%SZ")
)


def check_exists_all_indices(es, index_names):
Expand Down Expand Up @@ -72,7 +74,6 @@ def check_to_run_etl(es, index_names):

time_from_es = get_latest_time_indices_built(es, index_names)
latest_transaction_time = get_latest_utc_transaction_time()

if time_from_es is None or time_from_es < latest_transaction_time:
return True
return False
Expand All @@ -85,7 +86,8 @@ def timestamp_from_transaction_time(dt):
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%SZ")
# return datetime.strptime(iso_str, "%Y%m%dT%H%M%SZ")
return to_utc_time(datetime.strptime(iso_str, "%Y%m%dT%H%M%SZ"))


def putting_timestamp(es, index_to_write):
Expand Down

0 comments on commit b668a9d

Please sign in to comment.