Skip to content

Commit

Permalink
refactor: moves to using dto_retrieve to get sql
Browse files Browse the repository at this point in the history
using the detail dto_retrieve model to parse the sql responses returned
to the shillelagh, things to check post this commit

- can we get the detail fields when the user requests a model via where clause
- is this the right thing to do (moving away from using the sql_model configuration)

removes various TODO markers as appropriate where the issues have been resolved

refs #31
  • Loading branch information
devraj committed May 29, 2024
1 parent 0bcd691 commit cc1b767
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 15 deletions.
1 change: 0 additions & 1 deletion gallagher/cc/alarms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ async def get_config(cls) -> EndpointConfig:
endpoint=Capabilities.CURRENT.features.alarms.alarms,
dto_list=AlarmSummaryResponse,
dto_retrieve=AlarmDetail,
sql_model=AlarmSummary, # Temporary
)

@classmethod
Expand Down
4 changes: 0 additions & 4 deletions gallagher/cc/cardholders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

from ..core import Capabilities, APIEndpoint, EndpointConfig

# TODO: remove
from ...dto.summary import CardholderSummary

from ...dto.detail import (
CardholderDetail,
PdfDetail,
Expand All @@ -32,7 +29,6 @@ async def get_config(cls) -> EndpointConfig:
endpoint=Capabilities.CURRENT.features.cardholders.cardholders,
dto_list=CardholderSummaryResponse,
dto_retrieve=CardholderDetail,
sql_model=CardholderSummary, # Temporary
)

@classmethod
Expand Down
5 changes: 0 additions & 5 deletions gallagher/cc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,12 @@ class EndpointConfig:
dto_list: Optional[any] = None # DTO to be used for list requests
dto_retrieve: Optional[any] = None # DTO to be used for retrieve requests

sql_model: Optional[any] = None # SQL model to be used for SQL queries

top: Optional[int] = 10 # Number of response to download
sort: Optional[str] = "id" # Can be set to id or -id

fields: Tuple[str] = () # Optional list of fields, blank = all
search: Tuple[str] = () # If the endpoint supports search, blank = none

# TODO: prototyping shillelagh integration
sql = False # If the endpoint supports SQL queries

@classmethod
async def validate_endpoint(cls):
"""Check to see if the feature is licensed and available
Expand Down
7 changes: 2 additions & 5 deletions gallagher/ext/shillelagh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
from gallagher.cc.status_overrides import __shillelagh__ \
as status_overrides_tables

# TODO: get rid of this
from gallagher.cc.cardholders import Cardholder
class CCAPIAdapter(Adapter):

# Use this to log messages to assist with shillelagh debugging
Expand Down Expand Up @@ -99,8 +97,8 @@ class CCAPIAdapter(Adapter):

@staticmethod
def get_endpoint_urls() -> list[str]:
#TODO: we need to improve performance by cache this
#NOTE: this is a method because we need bootstrap to run first
# TODO: we need to improve performance by cache this
# NOTE: this is a method because we need bootstrap to run first
return [
f"{table.__config__.endpoint.href}" for table \
in CCAPIAdapter._all_tables
Expand Down Expand Up @@ -153,7 +151,6 @@ def supports(uri: str, fast: bool = True, **kwargs: Any) -> Optional[bool]:
return False

# Parse the base url using urlparse for comparison
# TODO: ensure this is loaded from the overridden API base
base_parsed_url = urllib.parse.urlparse(cc.api_base)

# Parse the endpoint using urlparse
Expand Down

0 comments on commit cc1b767

Please sign in to comment.