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: random entry #113

Merged
merged 6 commits into from
May 22, 2024
Merged

feat: random entry #113

merged 6 commits into from
May 22, 2024

Conversation

dag7dev
Copy link
Contributor

@dag7dev dag7dev commented May 14, 2024

Description

  • giving the usual endpoint API link, return a random entry, using the usual parameters
    Closes Play random entry #71

Copy link
Member

@avivace avivace left a comment

Choose a reason for hiding this comment

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

@dag7dev just an idea: maybe instead of ad-hoc endpoint random could simply be a query param that is available on the search endpoint? E.g.:

/search?random=true

Copy link
Member

@avivace avivace left a comment

Choose a reason for hiding this comment

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

Perfect! Just a minor comment to go ;)

API.md Outdated Show resolved Hide resolved
@@ -171,7 +174,7 @@ def search_entries(request):
# total number of pages
"page_total": paginator.num_pages,
# current request page
"page_current": page,
"page_current": int(page),
Copy link
Member

Choose a reason for hiding this comment

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

Why are casting to int here? Pagination is already trying to the desired page here so if something is wrong (e.g. page is a string) it already fails there (and goes to page 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will return a string otherwise, and... this is not consistent with the normal backend behavior

Copy link
Member

Choose a reason for hiding this comment

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

What? That's not true. At this line, page is used to paginate, if it's not a proper integer it would've failed there, so there's no way the code progress with page being a string.

Copy link
Member

@avivace avivace left a comment

Choose a reason for hiding this comment

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

Please also make sure to run pre-commit, as the checks are failing due to some unformatted file

@dag7dev
Copy link
Contributor Author

dag7dev commented May 18, 2024

Please also make sure to run pre-commit, as the checks are failing due to some unformatted file

not sure why it hasn't been ran automatically

@dag7dev
Copy link
Contributor Author

dag7dev commented May 20, 2024 via email

@dag7dev
Copy link
Contributor Author

dag7dev commented May 22, 2024

@avivace take a look. This is without the "int"
image

Same goes for other nums obviously:
image

This is with it and intended:
image

@avivace
Copy link
Member

avivace commented May 22, 2024

Ah alright, I understood what you mean, it's on the way back on the response

@avivace avivace merged commit aae5aca into gbdev:main May 22, 2024
1 check failed
@dag7dev dag7dev deleted the feat/71-random-entry branch May 22, 2024 08:27
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.

Play random entry
2 participants