add posts scope filter

This commit is contained in:
João Victor Geonizeli
2022-02-28 11:22:37 -03:00
parent e1f96c04a4
commit bf3253dc9e
5 changed files with 71 additions and 24 deletions

View File

@@ -0,0 +1,22 @@
class PostsQueryResolverService
attr_reader :filter, :current_user
def initialize(filter, current_user)
@filter = filter
@current_user = current_user
end
def self.call(filter, current_user)
new(filter, current_user).call
end
def call
scope = Post.all
if filter[:scope] == 'follows' && current_user
scope = scope.by_user_follows(current_user)
end
scope
end
end