Skip to content

Added sorting to the getResourceUpdates action#64

Open
MartenM wants to merge 4 commits into
SpigotMC:masterfrom
MartenM:patch-sorting-updates
Open

Added sorting to the getResourceUpdates action#64
MartenM wants to merge 4 commits into
SpigotMC:masterfrom
MartenM:patch-sorting-updates

Conversation

@MartenM

@MartenM MartenM commented Jan 21, 2022

Copy link
Copy Markdown

So this is just going by intuition and by looking at the existing code.
This PR is one of the suggestions made in issue #62

Added: RequestUtils:sorting()
Adds the sorting parameter. Returns NULL by default such that controllers can choose their default if required.

Changed Database->getResourceUpdates() parameters
Added the parameter $sorting = null. Defaults to asc which is the default right now I believe.
SQL got changed in order to add support for the sorting param.

Friendly note

These changes are UNTESTED since I don't have a database to test this on :)

@jacobsandersen

Copy link
Copy Markdown
Collaborator

Thank you! I will try and test this out soon.

@jacobsandersen

Copy link
Copy Markdown
Collaborator

Sorry for my absence, I will try to get to this soon.

@jacobsandersen jacobsandersen self-requested a review November 4, 2022 05:42

@jacobsandersen jacobsandersen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed up some syntax issues and a problem with PDO. Working as expected. LGTM

@jacobsandersen

Copy link
Copy Markdown
Collaborator

@frostalf will review and, pending approval, this is ready to go in @md-5

@MartenM sorry for the delay

@frostalf

frostalf commented Nov 9, 2022

Copy link
Copy Markdown

Looked over the code. However only one thing of note and that is the sort function. I am not sure what is being sorted or if the intention is to actually sort. strcasecmp() doesn't return anything except integers. -1 if the first string should come after the second, 0 if they are the same, and 1 if the first should come after the second. If what is intended is to actually return something sorted then what should be used is natcasesort(). Second, strcasecmp() only compares using ASCII, that is it is not locale aware. Otherwise everything else looks fine.

@jacobsandersen

Copy link
Copy Markdown
Collaborator

Looked over the code. However only one thing of note and that is the sort function. I am not sure what is being sorted or if the intention is to actually sort. strcasecmp() doesn't return anything except integers. -1 if the first string should come after the second, 0 if they are the same, and 1 if the first should come after the second. If what is intended is to actually return something sorted then what should be used is natcasesort(). Second, strcasecmp() only compares using ASCII, that is it is not locale aware. Otherwise everything else looks fine.

Thanks for the review. The sorting() method is for extracting params from the request. In this case it's reading the sort GET param, and then enforcing that it's equal to asc|ASC|desc|DESC. Then that is used in the database to decide what to pass into the query. The database is the one that does the actual sorting.

@frostalf

Copy link
Copy Markdown

Looked over the code. However only one thing of note and that is the sort function. I am not sure what is being sorted or if the intention is to actually sort. strcasecmp() doesn't return anything except integers. -1 if the first string should come after the second, 0 if they are the same, and 1 if the first should come after the second. If what is intended is to actually return something sorted then what should be used is natcasesort(). Second, strcasecmp() only compares using ASCII, that is it is not locale aware. Otherwise everything else looks fine.

Thanks for the review. The sorting() method is for extracting params from the request. In this case it's reading the sort GET param, and then enforcing that it's equal to asc|ASC|desc|DESC. Then that is used in the database to decide what to pass into the query. The database is the one that does the actual sorting.

Ah got it. Well looks good then lol 👍

@jacobsandersen

Copy link
Copy Markdown
Collaborator

@md_5 ready for merge? any comments? when you get time. thanks

@jacobsandersen

Copy link
Copy Markdown
Collaborator

oops i meant @md-5

@MartenM

MartenM commented Feb 15, 2023

Copy link
Copy Markdown
Author

I noticed a little error where there was an empty return statement so I snuck that commit in.

@jacobsandersen

Copy link
Copy Markdown
Collaborator

LGTM

@MartenM

MartenM commented Jun 21, 2023

Copy link
Copy Markdown
Author

👀

@jacobsandersen

Copy link
Copy Markdown
Collaborator

Hey @MartenM, haven't forgotten about this. Progress is a bit halted right now until api keys are done (very close) then we will take a look again at the PRs that are open including this one and get them in

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