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: get token by token_id API and add transactions count to token return #189

Merged
merged 15 commits into from
Aug 25, 2022

Conversation

andreabadesso
Copy link
Contributor

@andreabadesso andreabadesso commented Aug 15, 2022

Acceptance Criteria

  • We should have an API to retrieve a specific token by its token_id
  • We should add the transactions_count attribute to the token response
  • We should remove the transactions aggregation from the token information API

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@andreabadesso andreabadesso requested a review from r4mmer as a code owner August 15, 2022 16:08
@andreabadesso andreabadesso self-assigned this Aug 15, 2022
@andreabadesso andreabadesso marked this pull request as draft August 15, 2022 16:08
@lgtm-com
Copy link

lgtm-com bot commented Aug 15, 2022

This pull request introduces 1 alert when merging 87a1666 into f9ec34d - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@@ -51,18 +50,12 @@ def get_token_information(self, token_id: str) -> dict:
'field': 'address.keyword'
}
},
'transaction_sum': {
Copy link
Contributor Author

@andreabadesso andreabadesso Aug 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not only not needed as this information will be gathered by using the token index but it was invalid, as the aggregation is being limited by the max aggregation size from elastic search (limited at 1000 rows)

@lgtm-com
Copy link

lgtm-com bot commented Aug 15, 2022

This pull request introduces 1 alert when merging 3858cbf into f9ec34d - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@andreabadesso andreabadesso force-pushed the feat/get-token-transactions branch from 3858cbf to 9ee1c88 Compare August 17, 2022 13:49
@andreabadesso andreabadesso force-pushed the feat/get-token-transactions branch from 8284036 to de57330 Compare August 17, 2022 14:07
@andreabadesso andreabadesso force-pushed the feat/get-token-transactions branch 5 times, most recently from 471f188 to 821048d Compare August 19, 2022 06:46
@andreabadesso andreabadesso marked this pull request as ready for review August 19, 2022 06:47
@andreabadesso andreabadesso changed the title feat: get token API feat: get token by token_id API and add transactions count to token return Aug 19, 2022
@andreabadesso andreabadesso force-pushed the feat/get-token-transactions branch from 821048d to ad0f604 Compare August 22, 2022 13:55
serverless.yml Outdated Show resolved Hide resolved
handlers/token_api.py Outdated Show resolved Hide resolved
handlers/token_api.py Outdated Show resolved Hide resolved
tests/unit/usecases/test_token_api.py Show resolved Hide resolved
response = token_api.get_token(token_id)

if len(response['hits']) == 0:
raise ApiError("Token not found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will raise 500, right? should we raise ApiError("not_found") to return 404?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should, thanks!

Done in d45ebd0

serverless.yml Outdated
Comment on lines 290 to 294
- name: request.querystring.search_text
- name: request.querystring.sort_by
- name: request.querystring.order
- name: request.querystring.search_after
- name: request.header.origin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: request.querystring.search_text
- name: request.querystring.sort_by
- name: request.querystring.order
- name: request.querystring.search_after
- name: request.header.origin
- name: request.path.token_id
- name: request.header.origin

@@ -268,6 +268,31 @@ functions:
- name: request.querystring.search_after
- name: request.header.origin

# This get_token will get tokens from the elasticsearch index
es_get_token_handler:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this project style is to use snake case for lambda names but AWS translates to camel case replacing each underscore with Underscore for some internal names (e.g. policy statement name) this makes the name longer and easier to hit the limit, failing the deploy.

I think we should create new lambdas with camel case to avoid these issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's weird!

I'll open an issue to refactor lambda names to camelCase

@andreabadesso andreabadesso merged commit 2b1c311 into dev Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants