-
Notifications
You must be signed in to change notification settings - Fork 10
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
Y24-225 - [BUG] LabWhere location child count not updating correctly #813
Comments
Initial research suggests thats Location child_children count is not always in sync with the actual children count. This children_count column is controlled by a gem https://github.com/stefankroes/ancestry so its behaviour is obfuscated but its reference can be seen in the Location model. It could be as simple as writing a script to sync up the count but there is a concern as to why it is out of sync. Im not really sure this gem is needed as it doesn't really make sense to store children_count in the db when we can work it out dynamically with higher accuracy. My only thought would be its stored for performance reasons but I don't know if thats the only trade off with removing it? |
Findings: The children_count column is stored in the database for performance reasons, rather than being calculated dynamically. Initially, we managed the hierarchy manually, but this was later replaced by the Ancestry gem (possibly for performance reasons). The issue seems to be that the children_count column is managed by the Ancestry gem, but the gem is not updating it correctly in certain actions. Despite testing various actions like removing, adding, and moving labware/locations between parents, we have been unable to consistently reproduce the specific scenario where this issue occurs. The assumption is that something might be interfering with the Ancestry gem’s callbacks, potentially custom callbacks (e.g., before_save, after_create, etc.) in the Location model. Since a specific action causing this bug cannot be identified, understanding the root cause has been difficult. This is a known issue which is raised in ancestry repo stefankroes/ancestry#584 and the suggested solution is to to use rebuild_counter_cache stefankroes/ancestry#663. Currently a rake task is created to fix all out of sync children_count to correct values. P.S.: Labwhere logs have been checked for errors related to the Ancestry gem, but none were found. |
There are 129 location instances where the child count is incorrect
Location.all.filter { |l| l.children_count != l.children.count }.count
LabWhere is displaying the location's child_count attribute but this is not being updated from location.child.count
Above shows that location Sanger / Sulston / B105 has 9 children where it actually has 8
Acceptance criteria:
Contacts
nts, bt8
The text was updated successfully, but these errors were encountered: