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

Append new items to the top by default #42

Merged
merged 1 commit into from
Oct 22, 2013

Conversation

g4b0
Copy link

@g4b0 g4b0 commented Sep 4, 2013

No description provided.

@UndefinedOffset
Copy link
Owner

Thanks, I'll review this later this week given the build is failing I need to dig in further to find out the issue. I'll probably also default it to sorting to the bottom by default for backwards compatibility and performance. I may also rather than make it a global configuration option make it configurable on a per-instance basis.

@g4b0
Copy link
Author

g4b0 commented Sep 4, 2013

It's not working with many_many or with has_many relationship? I just tested it with has_many, but many_many modification is really trivial. It's ok append to the bottom by default, and the per-instance basis config it's really cool. Anyway I don't think appendig to the top will be a performance killer, since it's just a single query, not a php loop.

@UndefinedOffset
Copy link
Owner

You maybe able to narrow down the issue by looking at build 23.1 (23.2 is the same but 3.1 instead of 3.0 releases) https://travis-ci.org/UndefinedOffset/SortableGridField/builds/10973987

@g4b0
Copy link
Author

g4b0 commented Sep 6, 2013

working with has_many relationship, at line 216 $owner it's NULL during testing, but it works fine during normal usage. Maybe it's a test issue?

@UndefinedOffset
Copy link
Owner

It's possible, I'll look deeper this weekend and see if I can identify the issue.

@UndefinedOffset
Copy link
Owner

I've was fixing the failing test but and then realized something, your code has it updating all records in the table every time the loop iterates which may not be php heavy but it would be hard on the database when the dataset is large.

@UndefinedOffset
Copy link
Owner

However though this maybe the only solution, I think for this reason alone I'll default it to off by default and caution in the notes about large datasets. Also this will cause sql errors when there is no parent relationship like in the case of having the list be sorted on model admin which is why the test was failing.

@UndefinedOffset
Copy link
Owner

Sorry for the delay been really busy, I've created a new branch https://github.com/UndefinedOffset/SortableGridField/tree/experimental with this change merged in with a few modifications. Rather than make a default on or off for top sorting, it is a configuration method $inst->setAppendToTop(true), as well I've accounted for model admin. Do you mind testing in your env see if this solution works for you? If it does I'll merge the branch back into master and close this pull.

@g4b0
Copy link
Author

g4b0 commented Oct 22, 2013

It does work on my test environment. Good joob 👌

@UndefinedOffset
Copy link
Owner

cool i'll merge it to master hopefully today

@UndefinedOffset UndefinedOffset merged commit aa22298 into UndefinedOffset:master Oct 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants