This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vggonzal
authored and
vggonzal
committed
Aug 17, 2023
1 parent
198b238
commit 7e926fb
Showing
11 changed files
with
209 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,97 @@ | ||
# pylint: disable=W0613 | ||
"""Module to interface with DynamoDB database.""" | ||
|
||
|
||
import logging | ||
from datetime import datetime | ||
from typing import Generator | ||
|
||
import boto3 | ||
from .hydrocron_database import Hydrocron_DB | ||
from boto3.dynamodb.conditions import Key | ||
|
||
dynamodb = boto3.client('dynamodb') | ||
|
||
logger = logging.getLogger() | ||
|
||
|
||
def get_reach_series(start_time: datetime, end_time: datetime) -> Generator: | ||
table_name = 'hydrocron_swot_reaches_test' | ||
"""Get Timeseries for a particular Reach filtering by time range | ||
:param start_time: Start time of the timeseries | ||
:type start_time: str | ||
:param end_time: End time of the timeseries | ||
:type end_time: str | ||
:rtype: None | ||
""" | ||
|
||
response = dynamodb.get_item( | ||
TableName=table_name, | ||
TableName='hydrocron_swot_reaches_test', | ||
Key={ | ||
'reach_id': {'S': '71224100223'} | ||
} | ||
) | ||
print("get_item") | ||
print(response) | ||
return response | ||
|
||
|
||
def get_node_series(start_time: datetime, end_time: datetime) -> Generator: | ||
table_name = 'hydrocron_swot_reaches_test' | ||
"""Get Timeseries for a particular Node filtering by time range | ||
:param start_time: Start time of the timeseries | ||
:type start_time: str | ||
:param end_time: End time of the timeseries | ||
:type end_time: str | ||
:rtype: None | ||
""" | ||
|
||
response = dynamodb.get_item( | ||
TableName=table_name, | ||
TableName='hydrocron_swot_reaches_test', | ||
Key={ | ||
'node_id': {'S': '71224100223'} | ||
} | ||
) | ||
print("get_item") | ||
print(response) | ||
return response | ||
|
||
|
||
def get_reach_series_by_feature_id(feature_id: str, start_time: datetime, end_time: datetime) -> Generator: | ||
"""Get Timeseries for a particular Reach filtering by ID and time range | ||
#st = float(time.mktime(start_time.timetuple()) - 946710000) | ||
#et = float(time.mktime(end_time.timetuple()) - 946710000) | ||
:param feature_id: Identifier of the feature | ||
:type feature_id: str | ||
:param start_time: Start time of the timeseries | ||
:type start_time: str | ||
:param end_time: End time of the timeseries | ||
:type end_time: str | ||
:rtype: None | ||
""" | ||
|
||
#select * from reach where reach_id like %(feature_id)s and cast(time as float) >= %(start_time)s and cast(time as float) <= %(end_time)s""", | ||
table_name = 'hydrocron_swot_reaches_test' | ||
response = dynamodb.get_item( | ||
TableName=table_name, | ||
TableName='hydrocron_swot_reaches_test', | ||
Key={ | ||
'reach_id': {'S': feature_id} | ||
} | ||
) | ||
print("get_item") | ||
print(response) | ||
return response | ||
|
||
|
||
def get_node_series_by_feature_id(feature_id, start_time, end_time): | ||
"""Get Timeseries for a particular Node filtering by ID and time range | ||
:param feature_id: Identifier of the feature | ||
:type feature_id: str | ||
:param start_time: Start time of the timeseries | ||
:type start_time: str | ||
:param end_time: End time of the timeseries | ||
:type end_time: str | ||
:rtype: None | ||
""" | ||
table_name = 'hydrocron_swot_reaches_test' | ||
response = dynamodb.get_item( | ||
TableName=table_name, | ||
Key={ | ||
'node_id': {'S': feature_id} | ||
} | ||
) | ||
print(response) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.