Skip to content

Commit

Permalink
add assignable flags to user api
Browse files Browse the repository at this point in the history
  • Loading branch information
mwvolo committed Oct 7, 2024
1 parent cddf0db commit 6fea686
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/representers/api/v1/user_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ class UserRepresenter < Roar::Decorator
writeable: false

property :adopter_status,
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
type: String,
readable: true,
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
type: String,
readable: true,
writeable: false

property :salesforce_contact_id,
Expand Down Expand Up @@ -193,6 +193,14 @@ class UserRepresenter < Roar::Decorator
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
getter: ->(represented:, **) { represented.external_ids.map(&:external_id) }

property :assignable_school_integrated,
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
getter: ->(*) { self.school.has_assignable_contacts unless self.school.nil?}

property :assignable_user,
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
getter: ->(*) { self.external_ids.any? }

def to_hash(options = {})
# Avoid N+1 load on application_users.application
ActiveRecord::Associations::Preloader.new.preload represented.application_users.to_a, :application
Expand Down

0 comments on commit 6fea686

Please sign in to comment.