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

descendants_count counter cache? #586

Open
ptorrsmith opened this issue Jul 12, 2022 · 4 comments
Open

descendants_count counter cache? #586

ptorrsmith opened this issue Jul 12, 2022 · 4 comments
Assignees

Comments

@ptorrsmith
Copy link

We're wanting to implement a good way to cache the descendants_count on nodes in a similar way that children_count is set and maintained.

Has anyone attempted extending Ancestry to do this?

Currently we're looking at a pragmatic approach of having an async background job get queued up to update the ancestors of any added/removed node, but thinking this seems like it would be a nice extension for Ancestry.

@kbrock
Copy link
Collaborator

kbrock commented Aug 11, 2022

The counters are added as a one off and hardcoded into the code itself.
They end up needing to be hardcoded into the postgres only extension as well.

It would be great to be able to mixin these changes for those because both types of counters are extensions for the most part.

If you notice, they are defined in the postgres code and has_ancestry code.

sorry, thought I posted this a while ago.

@kbrock
Copy link
Collaborator

kbrock commented Mar 13, 2023

status update:

Making ok progress at updating the api so we can update the descendants count (hopefully for ruby and sql strategies. Thought I think I'd keep with ruby strategy for now)

@kbrock
Copy link
Collaborator

kbrock commented Mar 13, 2023

@ptorrsmith curious. Are you still using ancestry? Did you ever end up implementing this? Did you go the background job approach?

@ptorrsmith
Copy link
Author

@ptorrsmith curious. Are you still using ancestry? Did you ever end up implementing this? Did you go the background job approach?

Hi. Yes still following this. We ended up baking a post-run call to recalculate it and cache it. Would be good to have this as part of ancestry.

@kbrock kbrock self-assigned this Mar 14, 2023
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

No branches or pull requests

2 participants