Skip to content

Comments

validate class attachment#143

Merged
aryarm merged 27 commits intomasterfrom
validateClassAttachment
Mar 21, 2019
Merged

validate class attachment#143
aryarm merged 27 commits intomasterfrom
validateClassAttachment

Conversation

@aryarm
Copy link
Member

@aryarm aryarm commented Mar 21, 2019

resolves #136 and resolves #140

This PR adds proper validation to the classes.attach route. It ensures that class attachments do not create cycles in the class tree.
Validation works by first checking that the new parent of the class is not one of its descendants and then checking that the new children of the class are not one of its (new) ancestors. When a request fails validation, a detailed error message will be returned in the response.

I also made several other changes to improve the code.

  1. I created a new format for connections (which I refer to as the "separated connections format") for allowing isDescendant() and isAncestor() to perform simple intersection operations instead of using recursion to iterate through each connection.
  2. I made isDescendant() and isAncestor() more efficient. I also added the ability for them to find multiple descendants/ancestors at once and return them.
  3. I improved the ClassParentTableSeeder. It now creates nice looking trees instead of long sticks. I also added a parameter that provides more control over the number of classes that appear at the first level of the tree (under the root).
  4. I wrote a test suite for checking that validation in classes.attach works correctly.
  5. I reduced the number of queries performed by classes.attach.

aryarm added 25 commits March 1, 2019 20:07
consider moving it into a custom validation rule object. you can pass the params in the construct
… more control over the num of classes underneath the root
…y perform an intersection. makes them more efficient. see #140
@aryarm aryarm added this to the PHP Team - MVP milestone Mar 21, 2019
@aryarm aryarm self-assigned this Mar 21, 2019
@aryarm aryarm merged commit 92e9303 into master Mar 21, 2019
@aryarm aryarm deleted the validateClassAttachment branch March 21, 2019 04:22
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

Successfully merging this pull request may close these issues.

improve the ClassRepository's isDescendant and isAncestor functions validate class-class attachment

1 participant