@ -12,6 +12,7 @@ class OpenSourceProjectsController < ApplicationController
# GET /open_source_projects
# GET /open_source_projects
# GET /open_source_projects.json
# GET /open_source_projects.json
def index
def index
@app_dir = params [ :app_dir ]
@app_dir = params [ :app_dir ]
@language = params [ :language ]
@language = params [ :language ]
@created_at = params [ :created_at ]
@created_at = params [ :created_at ]
@ -25,6 +26,8 @@ class OpenSourceProjectsController < ApplicationController
@open_source_projects = @open_source_projects . offset ( @os_project_pages . offset ) . limit ( @os_project_pages . per_page )
@open_source_projects = @open_source_projects . offset ( @os_project_pages . offset ) . limit ( @os_project_pages . per_page )
@bugs = BugToOsp . order ( 'created_at desc' ) . limit ( 8 )
# @open_source_projects = OpenSourceProject.all
# @open_source_projects = OpenSourceProject.all
respond_to do | format |
respond_to do | format |
@ -76,25 +79,35 @@ class OpenSourceProjectsController < ApplicationController
end
end
end
end
def allbug
@bugs = BugToOsp . visible
def search
@bug_count = @bugs . count
@bug_pages = Paginator . new @bug_count , per_page_option , params [ 'page' ]
@bugs = @bugs . includes ( :bug ) . reorder ( " #{ RelativeMemo . table_name } .created_at DESC " ) . limit ( @bug_pages . per_page ) . offset ( @bug_pages . offset ) . all
respond_to do | format |
format . html
format . json { render json : @open_source_project }
end
end
end
def search
end
# added by yiang 暴力添加,请绕道
def showbug
def showmemo
@open_source_project = OpenSourceProject . find ( params [ :id ] )
@open_source_project = OpenSourceProject . find ( params [ :id ] )
sort_init 'updated_at' , 'desc'
sort_init 'updated_at' , 'desc'
sort_update 'created_at' = > " #{ RelativeMemo . table_name } .created_at " ,
sort_update 'created_at' = > " #{ RelativeMemo . table_name } .created_at " ,
'replies' = > " #{ RelativeMemo . table_name } .replies_count " ,
'replies' = > " #{ RelativeMemo . table_name } .replies_count " ,
'updated_at' = > " COALESCE (last_replies_relative_memos.created_at, #{ RelativeMemo . table_name } .created_at) "
'updated_at' = > " COALESCE (last_replies_relative_memos.created_at, #{ RelativeMemo . table_name } .created_at) "
@memo = RelativeMemo . new ( :open_source_project = > @open_source_project )
@memo = RelativeMemo . new ( :open_source_project = > @open_source_project )
@topic_count = @open_source_project . topic s. count
@topic_count = @open_source_project . bug s. count
@topic_pages = Paginator . new @topic_count , per_page_option , params [ 'page' ]
@topic_pages = Paginator . new @topic_count , per_page_option , params [ 'page' ]
@memos = @open_source_project . topic s.
@memos = @open_source_project . bug s.
reorder ( " #{ RelativeMemo . table_name } .sticky DESC " ) .
reorder ( " #{ RelativeMemo . table_name } .sticky DESC " ) .
includes ( :last_reply ) .
includes ( :last_reply ) .
limit ( @topic_pages . per_page ) .
limit ( @topic_pages . per_page ) .
@ -102,13 +115,42 @@ def showmemo
order ( sort_clause ) .
order ( sort_clause ) .
all
all
respond_to do | format |
respond_to do | format |
format . html {
format . html {
render :layout = > " base_opensource_p "
render :layout = > " base_opensource_p "
}
}
format . json { render json : @open_source_project }
format . json { render json : @open_source_project }
end
end
end
end
# added by yiang 暴力添加,请绕道
def showmemo
@open_source_project = OpenSourceProject . find ( params [ :id ] )
sort_init 'updated_at' , 'desc'
sort_update 'created_at' = > " #{ RelativeMemo . table_name } .created_at " ,
'replies' = > " #{ RelativeMemo . table_name } .replies_count " ,
'updated_at' = > " COALESCE (last_replies_relative_memos.created_at, #{ RelativeMemo . table_name } .created_at) "
@memo = RelativeMemo . new ( :open_source_project = > @open_source_project )
@topic_count = @open_source_project . topics . count
@topic_pages = Paginator . new @topic_count , per_page_option , params [ 'page' ]
@memos = @open_source_project . topics .
reorder ( " #{ RelativeMemo . table_name } .sticky DESC " ) .
includes ( :last_reply ) .
limit ( @topic_pages . per_page ) .
offset ( @topic_pages . offset ) .
order ( sort_clause ) .
all
respond_to do | format |
format . html {
render :layout = > " base_opensource_p "
}
format . json { render json : @open_source_project }
end
end
# GET /open_source_projects/new
# GET /open_source_projects/new
# GET /open_source_projects/new.json
# GET /open_source_projects/new.json
def new
def new
@ -178,13 +220,13 @@ end
def search
def search
# per_page_option = 10
# per_page_option = 10
#
#
# @open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at)
# @open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at)
# @open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present?
# @open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present?
#
#
# @os_project_count = @open_source_projects.count
# @os_project_count = @open_source_projects.count
# @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
# @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
#
#
# @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page)
# @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page)
redirect_to open_source_projects_path ( :name = > params [ :name ] )
redirect_to open_source_projects_path ( :name = > params [ :name ] )
@ -207,7 +249,6 @@ end
redirect_to master_apply_open_source_project_path
redirect_to master_apply_open_source_project_path
end
end
private
private
def require_master
def require_master