refactor welcome help
This commit is contained in:
parent
9f3d29a1f9
commit
49327905f8
|
@ -70,29 +70,29 @@ module WelcomeHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_project_by_hot
|
def sort_project_by_hot
|
||||||
return sort_project_by_hot_rails 0
|
sort_project_by_hot_rails 0, 'grade DESC'
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_course_by_hot
|
def sort_course_by_hot
|
||||||
return sort_project_by_hot_rails 1
|
sort_project_by_hot_rails 1, 'course_ac_para DESC'
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_bid_by_hot
|
def sort_bid_by_hot
|
||||||
return sort_bid_by_hot_rails 1
|
sort_bid_by_hot_rails 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_contest_by_hot
|
def sort_contest_by_hot
|
||||||
return sort_bid_by_hot_rails 2
|
sort_bid_by_hot_rails 2
|
||||||
end
|
end
|
||||||
#取得所有活动
|
#取得所有活动
|
||||||
def find_all_activities limit=10
|
def find_all_activities limit=10
|
||||||
users = []
|
# users = []
|
||||||
activities = Activity.find_by_sql("select distinct user_id from activities order by id DESC limit #{limit}" )
|
# activities = Activity.find_by_sql("select distinct user_id from activities order by id DESC limit #{limit}" )
|
||||||
activities.each { |activity|
|
# activities.each { |activity|
|
||||||
users << activity.user_id
|
# users << activity.user_id
|
||||||
}
|
# }
|
||||||
user_objs = User.find_by_sql("SELECT * FROM users WHERE (users.id IN #{"(" << users.join(',') << ")"} )")
|
# user_objs = User.find_by_sql("SELECT * FROM users WHERE (users.id IN #{"(" << users.join(',') << ")"} )")
|
||||||
activity = Redmine::Activity::Fetcher.new(user_objs)
|
activity = Redmine::Activity::Fetcher.new(nil)
|
||||||
|
|
||||||
activity.events_welcome(nil, nil, {:limit => limit})
|
activity.events_welcome(nil, nil, {:limit => limit})
|
||||||
end
|
end
|
||||||
|
@ -102,23 +102,16 @@ module WelcomeHelper
|
||||||
Memo.order('replies_count DESC').where('replies_count <> 0').limit(limit)
|
Memo.order('replies_count DESC').where('replies_count <> 0').limit(limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_project_by_hot_rails project_type
|
def sort_project_by_hot_rails project_type=0, order_by='grade DESC', limit=10
|
||||||
limit = 10
|
Project.find_by_sql("
|
||||||
project_type == 0 ? Project.find_by_sql("
|
|
||||||
SELECT p.id, p.name, p.description, p.identifier, t.project_id
|
SELECT p.id, p.name, p.description, p.identifier, t.project_id
|
||||||
FROM projects AS p RIGHT OUTER JOIN (
|
FROM projects AS p RIGHT OUTER JOIN (
|
||||||
SELECT project_id,grade FROM project_statuses
|
SELECT project_id,grade FROM project_statuses
|
||||||
WHERE project_type = #{project_type} ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
WHERE project_type = #{project_type} ORDER BY #{order_by} LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
||||||
: Project.find_by_sql("
|
|
||||||
SELECT p.id, p.name, p.description, p.identifier, t.project_id
|
|
||||||
FROM projects AS p RIGHT OUTER JOIN (
|
|
||||||
SELECT project_id,grade FROM project_statuses
|
|
||||||
WHERE project_type = #{project_type} ORDER BY course_ac_para DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_bid_by_hot_rails reward_type
|
def sort_bid_by_hot_rails reward_type, limit = 10
|
||||||
limit = 10
|
Bid.visible.where('reward_type = ?', reward_type).reorder('bids.commit desc').limit(limit)
|
||||||
Bid.visible.where('reward_type = ?', reward_type).reorder('bids.commit desc').limit(limit).all
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue