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