mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
pr check and send email
This commit is contained in:
29
app/queries/admins/glcc_examine_material.rb
Normal file
29
app/queries/admins/glcc_examine_material.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
class Admins::GlccExamineMaterial < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :created_on, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
materials = GlccMediumTermExamineMaterial.all
|
||||
|
||||
# term
|
||||
term = params[:term] || [1,2]
|
||||
if term.present?
|
||||
materials = materials.where(term: term)
|
||||
end
|
||||
#year
|
||||
year = if params[:date]
|
||||
params[:date][:year]
|
||||
end
|
||||
year = year || Time.now.year
|
||||
date = Time.now.change(year:year)
|
||||
materials = materials.where(created_on: [date.beginning_of_year..date.end_of_year])
|
||||
custom_sort(materials, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user