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

Notifications api endpoint #1347

Merged
merged 10 commits into from
Jun 27, 2024
Merged

Notifications api endpoint #1347

merged 10 commits into from
Jun 27, 2024

Conversation

KoalaSat
Copy link
Member

@KoalaSat KoalaSat commented Jun 21, 2024

What does this PR do?

This PR introduces a new API endpoint for the robot to fetch all notifications sent to it. To reduce bandwidth it allows to filter by the creation date.

A new table Notification has been created to have a place to store these notifications.

Checklist before merging

  • Install pre-commit and initialize it: pip install pre-commit, then pre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.

@KoalaSat KoalaSat mentioned this pull request Jun 21, 2024
1 task
Copy link
Collaborator

@Reckless-Satoshi Reckless-Satoshi left a comment

Choose a reason for hiding this comment

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

Thank you for adding these tests! This looks very ready. Left just a couple NIT comments :D

@@ -284,6 284,30 @@ paths:
type: string
description: Reason for the failure
description: ''
/api/notifications/:
Copy link
Collaborator

@Reckless-Satoshi Reckless-Satoshi Jun 22, 2024

Choose a reason for hiding this comment

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

By running the tests the API schema and redoc docs get updated with the new endpoint 👌

path = reverse("notifications")
params = f"?created_at={created_at}"
headers = self.get_robot_auth(robot_index, first_encounter)
self.response = self.client.get(path params, **headers)
Copy link
Collaborator

@Reckless-Satoshi Reckless-Satoshi Jun 22, 2024

Choose a reason for hiding this comment

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

During tests, trade.response is always the return of the latest GET to /api/order. Maybe here we want to create a new variable on the Trade class. for example: notification . This way, in tests we evaluate (assert) the value of trade.response for the latest state of an order, and of trade.notification for the latest notification, and don't get about what is the type of response.

I would therefore edit this one as:

self.notification = self.client.get(path   params, **headers)

notification or last_notification , the one name you prefer!

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up moving it out of Trade, I think it didn't make sense to have it there

@@ -802,6 955,17 @@ def test_taken_order_expires(self):

self.assert_order_logs(data["id"])

trade.get_notifications()
# Checks
self.assertResponse(trade.response)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we use trade.notification as the response stored by the get_notification() method, that will make tests more clear :)

@KoalaSat
Copy link
Member Author

Sorry for the confusion @Reckless-Satoshi 😆 test are not yet ready to be review, I'm investigating a possible wrong test on main

@KoalaSat KoalaSat force-pushed the notifications-api-endpoint branch 4 times, most recently from dfd7603 to 28620e9 Compare June 25, 2024 10:04
@KoalaSat KoalaSat force-pushed the notifications-api-endpoint branch 4 times, most recently from 08802b5 to 030663b Compare June 25, 2024 15:55
@KoalaSat
Copy link
Member Author

https://github.com/RoboSats/robosats/actions/runs/9686642409

@Reckless-Satoshi Reckless-Satoshi merged commit 1757a97 into main Jun 27, 2024
5 checks passed
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.

2 participants