mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
28
app/queries/users/video_query.rb
Normal file
28
app/queries/users/video_query.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
class Users::VideoQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
sort_columns :published_at, :title, default_by: :published_at, default_direction: :desc
|
||||
|
||||
attr_reader :user, :params
|
||||
|
||||
def initialize(user, params)
|
||||
@user = user
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
videos = user.videos
|
||||
|
||||
videos =
|
||||
case params[:status]
|
||||
when 'published' then videos.published
|
||||
when 'processing' then videos.processing
|
||||
else videos.published
|
||||
end
|
||||
|
||||
keyword = params[:keyword].to_s.strip
|
||||
videos = videos.where('title LIKE ?', "%#{keyword}%") if keyword.present?
|
||||
|
||||
custom_sort(videos, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user