Last active
January 30, 2018 22:06
-
-
Save stevepentler/9e0c8c08d66860c13d4aa647c8836518 to your computer and use it in GitHub Desktop.
Availability
This file contains hidden or 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
Availability: | |
Purpose: | |
- Assets contain their own state without any additional calls/relationships. | |
- single scope for assets, based on single field on Asset | |
- scale up features AND quicken load times | |
- clean up logic in views | |
Goals: | |
1. Expire Assets | |
2. Hold off on Publish date for Assets | |
3. Incorporate a more complicated approvals workflow | |
4. Bubble up the above 3 considerations into one "available" field on the Asset | |
Challenges: | |
1. Scope assets differently depending on permission level | |
- using scope that accepts permission level | |
- available(:adminable) { returns ALL Assets } | |
- available(:non_adminable) { returns ONLY available Assets } | |
- find all .assets calls and apply scope to all calls in API/Controllers & Views | |
Tech: | |
- Adds availability_start & availability_end fields to Assets | |
- Add availability field to Assets, make it an enumerable, default to 0 (approved/true) | |
0 = Available | |
1 = Expired (Date) | |
2 = Unpublished (Date) | |
3 = Pending (Approval) | |
- Create Scopes for available & unavailable | |
- AssetsService that accepts args(permission_level, resource_type, resource_id/resource_key) and returns scoped assets | |
- incoporate AssetsService into Controllers | |
- remove .assets references from views | |
- create indices (multiple fields) at db level for AssetsService | |
- Create AvailabilityService to handle logic that progresses enumerable | |
- Trigger AvailabilityJob that progresses assets on first minute of hour | |
- Index "states" for searchability in elastic search | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment