Skip to content

Commit

Permalink
fix: undo last commit change and instead remove which was causing the…
Browse files Browse the repository at this point in the history
… initial query to load all data then query again and then finally limit and offset
  • Loading branch information
ericenns committed Sep 17, 2024
1 parent d9afaff commit 45ac26a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
2 changes: 1 addition & 1 deletion app/graphql/resolvers/project_samples_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ProjectSamplesResolver < BaseResolver
default_value: nil

def resolve(filter:, order_by:)
ransack_obj = Sample.where(project_id: project.id).ransack(filter&.to_h)
ransack_obj = project.samples.ransack(filter&.to_h)
ransack_obj.sorts = ["#{order_by.field} #{order_by.direction}"] if order_by.present?

ransack_obj.result
Expand Down
9 changes: 0 additions & 9 deletions app/graphql/types/project_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,5 @@ def self.authorized?(object, context)
context: { user: context[:current_user], token: context[:token] }
)
end

def self.scope_items(items, context)
scope = authorized_scope Project, type: :relation,
context: { user: context[:current_user], token: context[:token] }
project_ids = items.pluck(:id)
scope.where(id: project_ids).in_order_of(:id, project_ids)
end

reauthorize_scoped_objects(false)
end
end
9 changes: 0 additions & 9 deletions app/graphql/types/sample_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,5 @@ def self.authorized?(object, context)
context: { user: context[:current_user], token: context[:token] }
)
end

def self.scope_items(items, context)
scope = authorized_scope Project, type: :relation,
context: { user: context[:current_user], token: context[:token] }
sample_ids = items.pluck(:id)
Sample.where(id: sample_ids, project_id: scope.select(:id)).in_order_of(:id, sample_ids)
end

reauthorize_scoped_objects(false)
end
end

0 comments on commit 45ac26a

Please sign in to comment.