Implement self ref fk ordering#322
Implement self ref fk ordering#322ozer550 wants to merge 7 commits intolearningequality:release-v0.9.xfrom
Conversation
| task.set_store(Store(**kwargs)) | ||
|
|
||
| @staticmethod | ||
| def _compute_self_ref_order(self_ref_fk_value): |
There was a problem hiding this comment.
So from our discussion on slack and seeing this, I think some of the behaviors have been taken very literally, which is my fault for not making that clearer.
if _self_ref_fk is None and the model is self-referential, the order field should be 0
otherwise, it should query for the parent's order (the Store._self_ref_order for id=_self_ref_fk)
We might need to query the database for this, but I think it's worth thinking through how and when this should occur. This satisfies the criteria of the behavior, but the engineering choices are up to you. The behaviors are not meant to be taken literally that this functionality should explicitly be placed here.
I say this for a couple reasons:
- Look at how we manage database calls-- in
StoreLookupwe do bulk queries for the store records, and howStoreUpdateactually does none. There's room for improvement in managing these queries. - The circumstances may not always work with the pipeline because it buffers records. On this note, I'm thinking in regards to this test case
test_handle_store_create__self_ref_parent_not_in_storeand whether that is an acceptable outcome.
More on (2): say we have our buffer batch size set to 2. In the first batch, we have a parent and a child. Since the batch size is two, the parent won't be saved yet when the child is processed, so this function should result in None. Then lets say batch #2 has two more children, of the first child (grandchildren). The function should find the store, but the store would have a None order, leading to None for the grandchildren. Thus we have a parent-child relationship which could get out of order because of None.
Summary
WIP
Short description
TODO
Reviewer guidance
If you PR has a significant size, give the reviewer some helpful remarks
Issues addressed
List the issues solved or partly solved by the PR
Documentation
If the PR has documentation, link the file here (either .rst in your repo or if built on Read The Docs)