Skip to content

Instantly share code, notes, and snippets.

@stevepentler
Last active February 9, 2018 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevepentler/97aa2269a18f622d5555535859ad0874 to your computer and use it in GitHub Desktop.
Save stevepentler/97aa2269a18f622d5555535859ad0874 to your computer and use it in GitHub Desktop.
Assets Service

1. Clean up the is_authorized? method (referenced by readable_by?/collabable_by?)

  • We inconsistently implement has_guest_password_access_to, so centralizing this will be helpful
  • has_guest_password_access_to belongs in authorization methods instead of an asset scope

2. We need to correct the expectation that we only made one query in the past, and we only need one query/scope in the future

3. The assets service does not handle org level searches well, but look at what it used to be...

Original: https://github.com/brandfolder/boulder/blob/master/app/controllers/api/v3/assets_controller.rb

Revised: https://github.com/brandfolder/boulder/blob/7ff318f5fb755726589f6d4524d15a1c365b9fab/app/controllers/api/v3/assets_controller.rb

  • note that this has the same amount of queries, and we never even used to scope to approved_only because of performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment