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

feat: truncate children in tx detail API to return at most 100 elements #350

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions common/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ def default(cls) -> "LogRenderer":
HEALTHCHECK_REDIS_ENABLED = config(
"HEALTHCHECK_REDIS_ENABLED", default=False, cast=bool
)

# API configuration
MAX_TX_CHILDREN = config("MAX_TX_CHILDREN", default=100)
7 changes: 7 additions & 0 deletions handlers/node_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from aws_lambda_context import LambdaContext

from common.configuration import MAX_TX_CHILDREN
from common.errors import ApiError
from usecases.node_api import NodeApi
from utils.wrappers.aws.api_gateway import ApiGateway, ApiGatewayEvent
Expand Down Expand Up @@ -176,6 +177,12 @@ def get_transaction(
if id is None:
raise ApiError("invalid_parameters")
response = node_api.get_transaction(id)
# It does not make sense to show in the explorer thousands of children.
# The full node will continue returning the correct data but in the explorer
# service we will truncate it and return only the latest MAX_TX_CHILDREN to show in the UI
# (it might even be more than we should, maybe we should paginate in the future)
if response is not None and "meta" in response and "children" in response["meta"]:
response["meta"]["children"] = response["meta"]["children"][-MAX_TX_CHILDREN:]

return {
"statusCode": 200,
Expand Down
Loading