This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…itor into resource-refactor
…end the entire user object
This was referenced Dec 10, 2018
Hey @bunjiboys Thanks for submitting this, we've some repo consolidation coming and core changes and will need time to review this...it likely won't happen until next year |
Hey @bunjiboys , we have some significant changes coming to backend and frontend so while a lot of this looks good, we'd probably need you to resubmit after the 2.1 release. Thanks |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a major refactor of how resources and issues are managed from a code perspective, similar to the Account Refactor (#173). All the changes in the PR are written to be fully backwards compatible with the existing codebase, albeit some functionality has been marked as deprecated in favor of the newer improved access patterns.
Property access and updating
Instead of manually implementing properties through
@property
methods on the object classes, you instead simply provide the property metadata and the Base classes will handle the property access.Old code
becomes
Since the metadata for the properties of each resource and issue type are new expressed in an easily digestable format, this also allows for generic resource view generation with good naming, which in almost all cases entirely removes the need for manually implementing any frontend code when adding a new type of resource or issue.
The update
BaseResource
andBaseIssue
class added a couple of new methods and properties to better support generic displays, while deprecating some older functionality.New BaseResource methods
find
This is an updated version of the existing
search
method, but where thesearch
method would only return objects of the same type as the class it was called on, thefind
method will allow you to return a collection of multiple resource types in a single query, allowing you to control which types to return by passing in a list of resource types through theresource_types
method argument.In order to provide similar functionality if called on an explicit resource type, it will only return results of that resource type, unless you also pass in one or more resource_types as an argument. Below is an example of first the old
search
method and then the newfind
methodOld:
New:
However, if you use the
BaseResource.find
method or pass in a list of resource_types to the find method, it will return a mixed collection instead.BaseResource
Typed search
All the returned objects will be cast into their proper resource type objects, allowing use of all the standard functionality on the objects as you'd expect.
Zero-indexed
One important difference between
search
andfind
is that the newfind
method is zero-indexed for paginationupdate_resource
/update_issue
This method handles updating any resource or issue objects properties, regardless of the type. It also allows for partial updates so that you only have to pass just the updated parameters for the object, and not have to send the entire set of properties when only some were changed.
For resources with tags, it does require you to pass the full set of tags in for the resource, as tags are handled as a set resource and not individual properties
Example