Comments (5)
Hi,
Sorry for late response but recently I'm very busy.
I don't fully understand your use case, exactly the part with assigning the new user to currently logged user. Could you explain it more to me? Which of those users are saved in DB, do they have set all tree related fields during calling setChildOf()
?
from eloquent-tree.
Hello,
No worries, totally understand.
We have a user currently logged in (A), created a new user (B). (A) has all tree related fields filled properly.
When doing (B)->setChildOf((A)), the call to findDescendants()
returns the whole users
table because (A) doesn't have the tree related fields filled (which is logic, the user has just been created).
Is it more clear ?
from eloquent-tree.
Yes, thanks.
Ok, so this code works, but the only problem is with performance right?
If I understand this correctly, we're checking for old descendants for the new node that doesn't have any, and this is why we're getting the whole table.
To fix that we'd probably need to check is this is the new node case (have an id or something) and only then try to find those descendants in DB.
Here is code responsible for that: https://github.com/AdrianSkierniewski/eloquent-tree/blob/master/src/Gzero/EloquentTree/Model/Tree.php#L79
from eloquent-tree.
Well, yeah, the problem is that it returns the whole table, inducing performance issue as soon as you have a few thousands users like we do.
What we do for now is we set the fields by hand, i.e. we don't call setChildOf
on newly created users, but it doesn't feel right. Feels more like a temp fix than a fix for life.
from eloquent-tree.
Fell free to create PR with proposed fix. If not, it will take me some time to create it due to a busy schedule.
from eloquent-tree.
Related Issues (10)
- getRoots() error HOT 1
- Setting multiple nodes as childs at once? HOT 2
- Can setAsRoot() be called automatically if parent_id is null ?
- Presenter HOT 4
- Laravel 5 Support HOT 1
- Laravel 5 HOT 2
- How to listen for and respond to fired events like updatedParent HOT 2
- Bug Tree::renderRecursiveTree() HOT 1
- My own table name HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eloquent-tree.