Skip to content

Unstable 2.0 - #106

Merged
ChrisLovering merged 41 commits into
mainfrom
unstable-2.0
Jun 20, 2021
Merged

ChrisLovering merged 41 commits into
mainfrom
unstable-2.0

Conversation

@ChrisLovering

@ChrisLovering ChrisLovering commented Jun 3, 2021 •

Copy link
Copy Markdown
Member

What does this PR do? Makes everything better of course!

Changes

  • Switch to Poetry & Python 3.9.5
    • There isn't a tiangolo 3.9.5 image, so we've made our own, based on the same script.
  • Split the different types of endpoints into their own files
    • This moves us away from having almost everything in pixels.py
  • Changed our manual auth implementation to use FastAPI's dependency injection pattern
    • This also meant I could remove the manual OpenAPI spec modifications we were doing to make the auth work in the docs
  • Use more of a RESTful style of endpoints, rather than having separate endpoints for get and post.
  • Moved all rate limit and cooldown config into constants.py

@vcokltfre

Copy link
Copy Markdown
Contributor

👁️ unstable but unstabler?

@ChrisLovering

Copy link
Copy Markdown
Member Author

Pls don't merge this...yet.

I need to summarise and change some readmes. This was just for the diff

@jb3
jb3 marked this pull request as draft June 3, 2021 23:24
@jb3

jb3 commented Jun 3, 2021

Copy link
Copy Markdown
Member

for your own protection.

Screenshot 2021-06-04 at 00 24 47

@ChrisLovering

Copy link
Copy Markdown
Member Author

for your own protection.

Screenshot 2021-06-04 at 00 24 47

Lol tyty

@ChrisLovering
ChrisLovering marked this pull request as ready for review June 4, 2021 21:13
@ChrisLovering
ChrisLovering marked this pull request as draft June 4, 2021 21:14
@ChrisLovering

Copy link
Copy Markdown
Member Author

This is ready for review, it shouldn't be merged until after the current event, due to some breaking changes.

@ChrisLovering

Copy link
Copy Markdown
Member Author

I am not sure how thoroughly this has been discussed, and how much of a say I have in this. But I have some opinions on the new endpoints, you currently have:

  • GET /size: Get the size of the canvas
  • GET /pixels: Get the whole canvas
  • GET /pixel: Get a specific pixel
  • PUT /pixel: Set a specific pixel

One quick thing I want to mention about /pixels, it doesn't really make sense, we're already at pixels.pythondiscord.com. Making the URL pixels.pythondiscord.com/pixels..

In my opinion, the following seem more RESTful:

  • GET /canvas/size: Get the size of the canvas alternatively this info could be included in the headers and would be mainly requested using HEAD /canvas.
  • GET /canvas: Get the whole canvas
    alternatively the following two endpoints could use /canvas/pixels
  • GET /canvas?x=x&y=y: Get a specific pixel
  • PUT /canvas: Set a specific pixel you could also use query parameters here and the body would only consist of the color

I actually really like that style of API, ready for the next time we run this event.

For now I believe I have covered all of your comments, once again, thanks for taking the time to ready through the PR :)

I will raise an issue with your suggestion for the re-work of the endpoints, rather than add more to this PR.

Comment thread pixels/endpoints/general.py
Comment thread pixels/endpoints/general.py
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/utils/auth.py Outdated
Comment thread pixels/canvas.py Outdated
Comment on lines 45 to 50
sql = (
"SELECT x, y, rgb "
"FROM current_pixel "
"WHERE x < $1 "
"AND y < $2"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did using multiline strings cause issues?

Comment thread pixels/canvas.py
Comment thread gunicorn_conf.py
Comment thread pixels/endpoints/general.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/utils/auth.py Outdated
Comment thread pixels/utils/auth.py Outdated

@Bluenix2 Bluenix2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pretty much only comment and doc-string improvements at this point

Comment thread scripts/test_endpoints.py Outdated
Comment thread gunicorn_conf.py
Comment thread pixels/models.py Outdated
Comment thread pixels/endpoints/general.py Outdated
Comment thread pixels/endpoints/general.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/utils/auth.py Outdated
Comment thread pixels/pixels.py Outdated
ChrisLovering and others added 8 commits June 20, 2021 18:05
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Comment thread pixels/utils/auth.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Comment thread pixels/endpoints/moderation.py Outdated
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Comment thread pixels/endpoints/moderation.py Outdated
Co-authored-by: Bluenix <bluenixdev@gmail.com>
Bluenix2
Bluenix2 previously approved these changes Jun 20, 2021
Comment thread pixels/endpoints/moderation.py Outdated
Co-authored-by: Bluenix <bluenixdev@gmail.com>
@ChrisLovering
ChrisLovering merged commit d98adad into main Jun 20, 2021
@ChrisLovering
ChrisLovering deleted the unstable-2.0 branch June 20, 2021 20:45
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.

6 participants