From 67e56210a68581eed7c537c7162463ba3d1636f8 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Wed, 18 Sep 2024 11:09:43 -0500 Subject: [PATCH] fix role filtering on contributors browse table --- server/app/graphql/types/browse_tables/browse_user_type.rb | 5 ----- .../app/models/materialized_views/user_browse_table_row.rb | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/server/app/graphql/types/browse_tables/browse_user_type.rb b/server/app/graphql/types/browse_tables/browse_user_type.rb index 5afe45824..645c127ad 100644 --- a/server/app/graphql/types/browse_tables/browse_user_type.rb +++ b/server/app/graphql/types/browse_tables/browse_user_type.rb @@ -2,7 +2,6 @@ module Types::BrowseTables class BrowseUserType < Types::Entities::UserType connection_type_class(Types::Connections::BrowseTableConnection) - @@role_mapping = User.roles.invert @@area_mapping = User.area_of_expertises.invert field :revision_count, Int, null: false @@ -12,10 +11,6 @@ def area_of_expertise @@area_mapping[object.area_of_expertise] end - def role - @@role_mapping[object.role] - end - def organizations Loaders::AssociationLoader.for(MaterializedViews::UserBrowseTableRow, :affiliations).load(object).then do |affil| affil.map do |a| diff --git a/server/app/models/materialized_views/user_browse_table_row.rb b/server/app/models/materialized_views/user_browse_table_row.rb index 06ed321f3..de3da68fa 100644 --- a/server/app/models/materialized_views/user_browse_table_row.rb +++ b/server/app/models/materialized_views/user_browse_table_row.rb @@ -1,4 +1,6 @@ class MaterializedViews::UserBrowseTableRow < MaterializedViews::MaterializedView has_many :affiliations, primary_key: :id, foreign_key: :user_id has_many :organizations, through: :affiliations + + enum role: ['curator', 'editor', 'admin'] end