Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
acoffman committed Sep 19, 2024
2 parents 064c20a + 05865db commit d9fc47d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 7 additions & 0 deletions server/app/admin/users_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
item :users, icon: "fa fa-user"
end

scopes do
User.roles.keys.each do |role|
scope role.capitalize.pluralize, -> { User.where(role: role) }
end
scope "Admins and Editors", -> { User.where(role: ['admin', 'editor']) }
end

search do |q|
q ? collection.where("username ILIKE ? OR name ILIKE ?", "%#{q}%", "%#{q}%") : collection
end
Expand Down
5 changes: 0 additions & 5 deletions server/app/graphql/types/browse_tables/browse_user_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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|
Expand Down
2 changes: 2 additions & 0 deletions server/app/models/materialized_views/user_browse_table_row.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d9fc47d

Please sign in to comment.