From 58b5dbdf9aa10eff7d281ff9d83377eda960c2e7 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Jan 2016 18:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=9C=80=E8=BF=91?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4=E6=97=B6=E9=97=B4=E5=AD=98?= =?UTF-8?q?=E5=85=A5=E6=95=B0=E6=8D=AE=E5=BA=93=20=E7=B2=BE=E5=93=81?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 8 ++++++++ app/helpers/application_helper.rb | 5 +++++ app/helpers/users_helper.rb | 5 ----- db/migrate/20160122094805_excellent_course.rb | 17 +++++++++++++++++ .../20160122094829_excellent_option_course.rb | 19 +++++++++++++++++++ db/schema.rb | 3 ++- 6 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20160122094805_excellent_course.rb create mode 100644 db/migrate/20160122094829_excellent_option_course.rb diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index cafec1c62..707e87fd1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -360,6 +360,9 @@ update end # end @changesets_latest_coimmit = @changesets[0] + unless @changesets[0].blank? + update_commits_date(@project, @changesets_latest_coimmit) + end @properties = @repository.properties(@path, @rev) @repositories = @project.repositories @course_tag = params[:course] @@ -589,6 +592,11 @@ update project.project_score.update_attribute(:changeset_num, count) end + # 更新项目提交次数时间 + def update_commits_date project, date + project.project_score.update_attribute(:commit_time, date.created_at) + end + def find_repository @repository = Repository.find(params[:id]) @project = @repository.project diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 51138f2ef..3a0808bdd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,6 +49,11 @@ module ApplicationHelper end end + def link_to_user_version(version, options = {}) + return '' unless version && version.is_a?(Version) + link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, :class => " f16 fb c_dblue " + end + # 判断课程是否为精品课程 def is_excellent_course course (course.is_excellent? or course.excellent_option?) ? true : false diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 43ef7cefc..bfc01a102 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -85,11 +85,6 @@ module UsersHelper end end - def link_to_user_version(version, options = {}) - return '' unless version && version.is_a?(Version) - link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, :class => " f16 fb c_dblue " - end - # 统计未读消息数 def unviewed_message(user) course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count diff --git a/db/migrate/20160122094805_excellent_course.rb b/db/migrate/20160122094805_excellent_course.rb new file mode 100644 index 000000000..465b81464 --- /dev/null +++ b/db/migrate/20160122094805_excellent_course.rb @@ -0,0 +1,17 @@ +class ExcellentCourse < ActiveRecord::Migration + def up + arr = [302,192,370,394,183,361,117,218,379,178,418,203,342,403,225] + for i in 0..arr.length-1 + begin + puts arr[i] + course = Course.find(arr[i]) + course.update_attribute(:is_excellent, true) + rescue + logger.error("Course is not found!") + end + end + end + + def down + end +end diff --git a/db/migrate/20160122094829_excellent_option_course.rb b/db/migrate/20160122094829_excellent_option_course.rb new file mode 100644 index 000000000..30ee53ba3 --- /dev/null +++ b/db/migrate/20160122094829_excellent_option_course.rb @@ -0,0 +1,19 @@ +class ExcellentOptionCourse < ActiveRecord::Migration + def up + arr = [151,122,15,227,139,410,291,224,55,137,414,43,417,52,205,44,216,132,204,258,411,50, + 419,390,420,133,91,112,202,95,194,34,172,403,177,252,138,352,225,46,279,382,397,286,344,27,175, + 124,265,88,59,110,72,92,392,413,26,201,94,57,156,393,154,12,262] + for i in 0..arr.length-1 + begin + puts arr[i] + course = Course.find(arr[i]) + course.update_attribute(:excellent_option, true) + rescue + logger.error("Course is not found!") + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 7e6291806..fb021e9ae 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160122083507) do +ActiveRecord::Schema.define(:version => 20160122094829) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1372,6 +1372,7 @@ ActiveRecord::Schema.define(:version => 20160122083507) do t.integer "board_message_num", :default => 0 t.integer "board_num", :default => 0 t.integer "attach_num", :default => 0 + t.datetime "commit_time" end create_table "project_statuses", :force => true do |t|