Skip to content

Instantly share code, notes, and snippets.

@fmundaca
Created May 13, 2021 15:10
Show Gist options
  • Save fmundaca/77be426aa74281f59d7b9c62d76b979b to your computer and use it in GitHub Desktop.
Save fmundaca/77be426aa74281f59d7b9c62d76b979b to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
module Administration
module PositionsManagement
class PositionPrint < Blueprinter::Base
view :successed do
identifier :id
fields :name, :code, :token, :parent_id, :description, :children_count
field :total_collaborators do |position|
User.where(area_id: position.self_and_descendants.ids).count
end
field :total_descendants do |position|
position.descendants.size
end
end
view :errored do
field :errors do |position|
position.errors.messages.values.flatten
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment