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

Added sorting to the getResourceUpdates action #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MartenM
Copy link

@MartenM MartenM commented Jan 21, 2022

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
Collaborator

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

@jacobsandersen
Copy link
Collaborator

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

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

@jacobsandersen jacobsandersen left a comment

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
Collaborator

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

@MartenM sorry for the delay

@frostalf
Copy link

frostalf commented Nov 9, 2022

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
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

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
Collaborator

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

@jacobsandersen
Copy link
Collaborator

oops i meant @md-5

@MartenM
Copy link
Author

MartenM commented Feb 15, 2023

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

@jacobsandersen
Copy link
Collaborator

LGTM

@MartenM
Copy link
Author

MartenM commented Jun 21, 2023

👀

@jacobsandersen
Copy link
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