@ -37,16 +37,16 @@ module WelcomeHelper
end
def find_all_hot_course
sort_course_by_hot
sort_course_by_hot
end
def find_all_hot_bid
sort_bid_by_hot
sort_bid_by_hot
end
def find_all_hot_contest
sort_contest_by_hot
end
def find_all_hot_contest
sort_contest_by_hot
end
private
@ -70,45 +70,54 @@ module WelcomeHelper
end
def sort_project_by_hot
return sort_project_by_hot_rails 0
end
def sort_course_by_hot
return sort_project_by_hot_rails 1
end
def sort_bid_by_hot
return sort_bid_by_hot_rails 1
end
def sort_contest_by_hot
return sort_bid_by_hot_rails 2
end
#取得所有活动
def find_all_activities
end
#取得论坛数据
def find_hot_forum_topics
end
def sort_project_by_hot_rails project_type
limit = 10
project_type == 0 ? 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 grade DESC 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
def sort_bid_by_hot_rails reward_type
limit = 10
Bid . visible . where ( 'reward_type = ?' , reward_type ) . reorder ( 'bids.commit desc' ) . limit ( limit ) . all
end
return sort_project_by_hot_rails 0
end
def sort_course_by_hot
return sort_project_by_hot_rails 1
end
def sort_bid_by_hot
return sort_bid_by_hot_rails 1
end
def sort_contest_by_hot
return sort_bid_by_hot_rails 2
end
#取得所有活动
def find_all_activities limit = 10
users = [ ]
activities = Activity . find_by_sql ( " select distinct user_id from activities order by id DESC limit #{ limit } " )
activities . each { | activity |
users << activity . user_id
}
user_objs = User . find_by_sql ( " SELECT * FROM users WHERE (users.id IN #{ " ( " << users . join ( ',' ) << " ) " } ) " )
activity = Redmine :: Activity :: Fetcher . new ( user_objs )
activity . events_welcome ( nil , nil , { :limit = > limit } )
end
#取得论坛数据
def find_hot_forum_topics
end
def sort_project_by_hot_rails project_type
limit = 10
project_type == 0 ? 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 grade DESC 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
def sort_bid_by_hot_rails reward_type
limit = 10
Bid . visible . where ( 'reward_type = ?' , reward_type ) . reorder ( 'bids.commit desc' ) . limit ( limit ) . all
end
end