Giter Site home page Giter Site logo

Comments (5)

AdrianSkierniewski avatar AdrianSkierniewski commented on July 18, 2024

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.

jbajou avatar jbajou commented on July 18, 2024

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.

AdrianSkierniewski avatar AdrianSkierniewski commented on July 18, 2024

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.

jbajou avatar jbajou commented on July 18, 2024

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.

AdrianSkierniewski avatar AdrianSkierniewski commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.