From 356de5e8a4fe1995ef7585dd0e1515a56f13821d Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Fri, 8 Nov 2019 15:12:36 +0800
Subject: [PATCH 1/8] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/trustie_hacks_controller.rb | 2 +-
app/models/trustie_hack.rb | 1 +
app/models/trustie_hackathon.rb | 2 +-
.../20191108070703_modify_descriotion_limit_for_hacks.rb | 6 ++++++
4 files changed, 9 insertions(+), 2 deletions(-)
create mode 100644 db/migrate/20191108070703_modify_descriotion_limit_for_hacks.rb
diff --git a/app/controllers/trustie_hacks_controller.rb b/app/controllers/trustie_hacks_controller.rb
index 803809124..22a7a2976 100644
--- a/app/controllers/trustie_hacks_controller.rb
+++ b/app/controllers/trustie_hacks_controller.rb
@@ -1,5 +1,5 @@
class TrustieHacksController < ApplicationController
- before_action :require_admin, :except => [:index]
+ before_action :require_admin, :except => [:index, :entry]
before_action :require_login, :except => [:index]
before_action :find_hackathon
before_action :find_hack, :except => [:create, :index, :edit_hackathon, :update_hackathon]
diff --git a/app/models/trustie_hack.rb b/app/models/trustie_hack.rb
index b436007ca..7c2f3264b 100644
--- a/app/models/trustie_hack.rb
+++ b/app/models/trustie_hack.rb
@@ -1,4 +1,5 @@
class TrustieHack < ApplicationRecord
+ validates_length_of :description, maximum: 500
has_many :hack_users, :dependent => :destroy
belongs_to :trustie_hackathon, counter_cache: true
diff --git a/app/models/trustie_hackathon.rb b/app/models/trustie_hackathon.rb
index 7269e7856..65275099d 100644
--- a/app/models/trustie_hackathon.rb
+++ b/app/models/trustie_hackathon.rb
@@ -1,5 +1,5 @@
class TrustieHackathon < ApplicationRecord
-
+ validates_length_of :description, maximum: 500
has_many :trustie_hacks, :dependent => :destroy
end
diff --git a/db/migrate/20191108070703_modify_descriotion_limit_for_hacks.rb b/db/migrate/20191108070703_modify_descriotion_limit_for_hacks.rb
new file mode 100644
index 000000000..9168dbd2a
--- /dev/null
+++ b/db/migrate/20191108070703_modify_descriotion_limit_for_hacks.rb
@@ -0,0 +1,6 @@
+class ModifyDescriotionLimitForHacks < ActiveRecord::Migration[5.2]
+ def change
+ change_column :trustie_hackathons, :description, :text
+ change_column :trustie_hacks, :description, :text
+ end
+end
From f47dbb2c27b1dd97f4096dce32cbbaf490fa3bd7 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Fri, 8 Nov 2019 15:16:43 +0800
Subject: [PATCH 2/8] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E7=9A=84=E8=B0=83=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../homework_commons_controller.rb | 2 +-
app/controllers/student_works_controller.rb | 24 ++++++++++++++++-
app/helpers/student_works_helper.rb | 4 +--
app/models/student_work.rb | 6 ++---
.../shixun_work/shixun_work.html.erb | 17 ++++++------
.../shixun_work_report.json.jbuilder | 27 ++++++++++---------
6 files changed, 52 insertions(+), 28 deletions(-)
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 4bf80765c..a09db6308 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -1512,7 +1512,7 @@ class HomeworkCommonsController < ApplicationController
end_time = game.end_time
# 用户关卡的得分
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f
- final_score = @student_work.work_challenge_score game, all_score
+ final_score = @student_work.work_challenge_score game, all_score, challenge.id
# 抄袭用户
copy_user = User.find_by_id(game_codes[0].try(:target_user_id))
copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present?
diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb
index de764992b..96307df8d 100644
--- a/app/controllers/student_works_controller.rb
+++ b/app/controllers/student_works_controller.rb
@@ -464,6 +464,7 @@ class StudentWorksController < ApplicationController
@shixun = @homework.shixuns.take
# 提示: 这里如果includes outputs表的话: sum(:evaluate_count)会出现错误
@games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun
+ @challenges = @shixun.challenges if @shixun
@comment = @work.shixun_work_comments.find_by(challenge_id: 0)
# 用户最大评测次数
@@ -517,6 +518,7 @@ class StudentWorksController < ApplicationController
@user = @work.user
@shixun = @homework.shixuns.take
@games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun
+ @challenges = @shixun.challenges if @shixun
# 用户最大评测次数
@user_evaluate_count = @games.pluck(:evaluate_count).sum if @games
@@ -727,7 +729,11 @@ class StudentWorksController < ApplicationController
challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
comment: comment)
challenge_score.create_tiding current_user.id
- HomeworksService.new.update_myshixun_work_score @work, @work&.myshixun, @work&.myshixun&.games, @homework, @homework.homework_challenge_settings
+ if @work.work_status != 0 && @work.myshixun
+ HomeworksService.new.update_myshixun_work_score @work, @work.myshixun, @work.myshixun&.games, @homework, @homework.homework_challenge_settings
+ else
+ update_none_commit_work @work, @homework
+ end
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
@@ -855,4 +861,20 @@ class StudentWorksController < ApplicationController
end
end
end
+
+ def update_none_commit_work work, homework
+ if work.work_status == 0
+ work.work_status = 1
+ work.commit_time = homework.end_time
+ work.update_time = Time.now
+ end
+ final_score = 0
+ homework.homework_challenge_settings.each do |cha_setting|
+ adjust_score = work.challenge_work_scores.select{|work_score| work_score.challenge_id == cha_setting.challenge_id}.last
+ final_score += adjust_score.score if adjust_score.present?
+ end
+ work.final_score = final_score
+ work.work_score = final_score
+ work.save!
+ end
end
diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb
index 73d12aa2f..40759c9e0 100644
--- a/app/helpers/student_works_helper.rb
+++ b/app/helpers/student_works_helper.rb
@@ -19,7 +19,7 @@ module StudentWorksHelper
# 作业的开启时间
def myshixun_open_time game
- game.open_time ? (format_time game.open_time) : "--"
+ game&.open_time ? (format_time game.open_time) : "--"
end
# 作业完成时间
@@ -29,7 +29,7 @@ module StudentWorksHelper
# 作业耗时
def time_consuming game
- game.end_time.blank? ? "--" : (game_spend_time game.cost_time)
+ game&.end_time.blank? ? "--" : (game_spend_time game.cost_time)
end
# 用户个人实训总得分:user_total_score;
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index 2e7f843ae..8477da774 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -196,12 +196,12 @@ class StudentWork < ApplicationRecord
student_works_scores.where.not(reviewer_role: 3, score: nil).exists?
end
- def work_challenge_score game, score
+ def work_challenge_score game, score, challenge_id
game_score = 0
- adjust_score = challenge_work_scores.where(challenge_id: game.challenge_id).last
+ adjust_score = challenge_work_scores.where(challenge_id: challenge_id).last
if adjust_score.present?
game_score = adjust_score.score
- else
+ elsif game.present?
setting = homework_common.homework_group_setting game.user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time))
answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation
diff --git a/app/templates/shixun_work/shixun_work.html.erb b/app/templates/shixun_work/shixun_work.html.erb
index c4ea11f1e..bbc81f373 100644
--- a/app/templates/shixun_work/shixun_work.html.erb
+++ b/app/templates/shixun_work/shixun_work.html.erb
@@ -76,22 +76,23 @@
调分 |
- <% @games.each_with_index do |game, index| %>
- <% challenge_score = @homework.challenge_score game.challenge_id %>
- <% game_score = @work.work_challenge_score game, challenge_score %>
+ <% @challenges.each_with_index do |challenge, index| %>
+ <% challenge_score = @homework.challenge_score challenge.id %>
+ <% game = @games.select{|game| game.challenge_id == challenge.id}.first if @games %>
+ <% game_score = @work.work_challenge_score game, challenge_score, challenge.id %>
<%= index + 1 %> |
- <%= game.challenge.subject %>
- <% if ((Time.now > @homework.end_time) && game.end_time.blank?) || (game.end_time.present? && game.end_time > @homework.end_time) %>
+ <%= challenge.subject %>
+ <% if game && (((Time.now > @homework.end_time) && game.end_time.blank?) || (game.end_time.present? && game.end_time > @homework.end_time)) %>
延时
<% end %>
|
<%= myshixun_open_time(game) %> |
- <%= game.evaluate_count %> |
- <%= finished_time game.end_time %> |
+ <%= game ? game&.evaluate_count : 0 %> |
+ <%= game ? finished_time(game.end_time) : "--" %> |
<%= ApplicationController.helpers.time_consuming game %> |
- <%= game.final_score %> / <%= game.challenge.all_score %> |
+ <%= game ? game.final_score : 0 %> / <%= challenge.all_score %> |
<%= game_score %> / <%= challenge_score %> |
<%= game_score %> |
diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder
index 862a6be50..e3a515e7a 100644
--- a/app/views/student_works/shixun_work_report.json.jbuilder
+++ b/app/views/student_works/shixun_work_report.json.jbuilder
@@ -22,25 +22,26 @@ if @shixun
# 阶段成绩
json.stage_list do
- json.array! @games do |game|
- json.name game.challenge.subject
- json.is_delay student_work_is_delay?(@homework, game)
+ json.array! @challenges do |challenge|
+ json.name challenge.subject
+ game = @games.select{|game| game.challenge_id == challenge.id}.first if @games
+ json.is_delay game ? student_work_is_delay?(@homework, game) : false
json.open_time myshixun_open_time game
- json.evaluate_count game.evaluate_count
- json.finished_time finished_time game.end_time
+ json.evaluate_count game ? game&.evaluate_count : 0
+ json.finished_time game ? finished_time game.end_time : "--"
json.time_consuming time_consuming game
- json.myself_experience game.final_score
- json.experience game.challenge.all_score
- json.complete_status game_status(game, @homework)
- json.challenge_id game.challenge_id
- challenge_score = @homework.challenge_score game.challenge_id
+ json.myself_experience game ? game&.final_score : 0
+ json.experience challenge.all_score
+ json.complete_status game ? game_status(game, @homework) : 0
+ json.challenge_id challenge.id
+ challenge_score = @homework.challenge_score challenge.id
json.game_score_full challenge_score
- json.game_score @work.work_challenge_score game, challenge_score
- challenge_comment = @work.shixun_work_comments.find_by(challenge_id: game.challenge_id)
+ json.game_score @work.work_challenge_score game, challenge_score, challenge.id
+ challenge_comment = @work.shixun_work_comments.find_by(challenge_id: challenge.id)
json.challenge_comment challenge_comment&.comment
json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil
json.comment_id challenge_comment&.id
- json.view_answer game.answer_open != 0
+ json.view_answer game ? game.answer_open != 0 : 0
end
end
From b69ea499fee56c3ec640c882f4164b4b27f28385 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Fri, 8 Nov 2019 15:21:50 +0800
Subject: [PATCH 3/8] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E8=B0=83=E5=88=86=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/student_works/shixun_work_report.json.jbuilder | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder
index e3a515e7a..f6ca05bec 100644
--- a/app/views/student_works/shixun_work_report.json.jbuilder
+++ b/app/views/student_works/shixun_work_report.json.jbuilder
@@ -7,7 +7,7 @@ if @shixun
json.shixun_name @shixun.name
# 总体评价
json.overall_appraisal @work.overall_appraisal
- json.myself_experience @work.myshixun.try(:total_score)
+ json.myself_experience @work.myshixun.try(:total_score).to_i
json.total_experience @shixun.all_score
json.work_score number_with_precision @work.work_score, precision: 1
json.all_work_score number_with_precision 100, precision: 1
@@ -28,7 +28,7 @@ if @shixun
json.is_delay game ? student_work_is_delay?(@homework, game) : false
json.open_time myshixun_open_time game
json.evaluate_count game ? game&.evaluate_count : 0
- json.finished_time game ? finished_time game.end_time : "--"
+ json.finished_time game ? finished_time(game.end_time) : "--"
json.time_consuming time_consuming game
json.myself_experience game ? game&.final_score : 0
json.experience challenge.all_score
From 9e6d6ab36e12db2980e39583eb07f5e73d7058c0 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Fri, 8 Nov 2019 15:29:01 +0800
Subject: [PATCH 4/8] =?UTF-8?q?=E8=B0=83=E5=88=86=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_works_controller.rb | 2 +-
app/views/student_works/shixun_work_report.json.jbuilder | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb
index 58406467d..dda677802 100644
--- a/app/controllers/student_works_controller.rb
+++ b/app/controllers/student_works_controller.rb
@@ -721,7 +721,7 @@ class StudentWorksController < ApplicationController
challenge_setting = @homework.homework_challenge_settings.find_by(challenge_id: params[:challenge_id])
challenge = challenge_setting&.challenge
tip_exception("不能小于零") if params[:score].to_i < 0
- tip_exception("不能大于关卡分值:#{challenge_setting.score}分") if challenge_setting.score < params[:score].to_i
+ tip_exception("不能大于关卡分值:#{challenge_setting.score}分") if challenge_setting && challenge_setting.score < params[:score].to_i
ActiveRecord::Base.transaction do
begin
diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder
index f6ca05bec..cda78d93c 100644
--- a/app/views/student_works/shixun_work_report.json.jbuilder
+++ b/app/views/student_works/shixun_work_report.json.jbuilder
@@ -9,15 +9,15 @@ if @shixun
json.overall_appraisal @work.overall_appraisal
json.myself_experience @work.myshixun.try(:total_score).to_i
json.total_experience @shixun.all_score
- json.work_score number_with_precision @work.work_score, precision: 1
+ json.work_score number_with_precision @work.work_score.to_f.round(2), precision: 1
json.all_work_score number_with_precision 100, precision: 1
json.time_consuming @work.myshixun_consume
json.evaluate_count @user_evaluate_count.to_i
if @homework.work_efficiency
json.eff_score_full number_with_precision @homework.eff_score, precision: 1
- json.eff_score number_with_precision @work.eff_score, precision: 1
+ json.eff_score number_with_precision @work.eff_score.to_f.round(2), precision: 1
json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1
- json.challenge_score number_with_precision @work.final_score, precision: 1
+ json.challenge_score number_with_precision @work.final_score.to_f.round(2), precision: 1
end
# 阶段成绩
@@ -53,7 +53,7 @@ if @shixun
json.username @user.real_name
json.student_id @user.student_id
json.image_url url_to_avatar(@user)
- json.complete_count @work.myshixun&.passed_count
+ json.complete_count @work.myshixun&.passed_count.to_i
json.challenges_count @shixun.challenges_count
json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil
json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil
From d431b36b02dc0f14601a20cf8c57bbe8aa1ee489 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Fri, 8 Nov 2019 15:31:20 +0800
Subject: [PATCH 5/8] =?UTF-8?q?=E8=B0=83=E5=88=86=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_works_controller.rb | 48 +++++++++++----------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb
index dda677802..ad684952d 100644
--- a/app/controllers/student_works_controller.rb
+++ b/app/controllers/student_works_controller.rb
@@ -719,31 +719,35 @@ class StudentWorksController < ApplicationController
tip_exception("参数错误,score和challenge_id不能为空")
end
challenge_setting = @homework.homework_challenge_settings.find_by(challenge_id: params[:challenge_id])
- challenge = challenge_setting&.challenge
- tip_exception("不能小于零") if params[:score].to_i < 0
- tip_exception("不能大于关卡分值:#{challenge_setting.score}分") if challenge_setting && challenge_setting.score < params[:score].to_i
+ if challenge_setting
+ challenge = challenge_setting&.challenge
+ tip_exception("不能小于零") if params[:score].to_i < 0
+ tip_exception("不能大于关卡分值:#{challenge_setting.score}分") if challenge_setting && challenge_setting.score < params[:score].to_i
- ActiveRecord::Base.transaction do
- begin
- if params[:type] == "review"
- copy_user = User.find params[:copy_user_id]
- comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%"
- else
- comment = "根据实训报告中最终提交的代码调整第#{challenge.position}关分数"
- end
- challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
- comment: comment)
- challenge_score.create_tiding current_user.id
- if @work.work_status != 0 && @work.myshixun
- HomeworksService.new.update_myshixun_work_score @work, @work.myshixun, @work.myshixun&.games, @homework, @homework.homework_challenge_settings
- else
- update_none_commit_work @work, @homework
+ ActiveRecord::Base.transaction do
+ begin
+ if params[:type] == "review"
+ copy_user = User.find params[:copy_user_id]
+ comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%"
+ else
+ comment = "根据实训报告中最终提交的代码调整第#{challenge.position}关分数"
+ end
+ challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
+ comment: comment)
+ challenge_score.create_tiding current_user.id
+ if @work.work_status != 0 && @work.myshixun
+ HomeworksService.new.update_myshixun_work_score @work, @work.myshixun, @work.myshixun&.games, @homework, @homework.homework_challenge_settings
+ else
+ update_none_commit_work @work, @homework
+ end
+ rescue Exception => e
+ uid_logger(e.message)
+ tip_exception("调分失败")
+ raise ActiveRecord::Rollback
end
- rescue Exception => e
- uid_logger(e.message)
- tip_exception(e.message)
- raise ActiveRecord::Rollback
end
+ else
+ tip_exception("该关卡不记分")
end
end
From cfdb17e24f4818219a500df8c97ea2d1ad24f650 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Fri, 8 Nov 2019 15:34:51 +0800
Subject: [PATCH 6/8] 1
---
app/controllers/trustie_hacks_controller.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/trustie_hacks_controller.rb b/app/controllers/trustie_hacks_controller.rb
index 22a7a2976..0ae56383c 100644
--- a/app/controllers/trustie_hacks_controller.rb
+++ b/app/controllers/trustie_hacks_controller.rb
@@ -49,10 +49,10 @@ class TrustieHacksController < ApplicationController
# 报名入口
def entry
- if @hack.hack_users.exists?(user_id: current_user)
+ if @hack.hack_users.exists?(user_id: current_user.id)
render_error('已经报名,请勿重复操作')
else
- @hack.hack_users.create(user_id: current_user)
+ @hack.hack_users.create(user_id: current_user.id)
render_ok
end
end
From 46d839684a5f59888b4fa2151c09a9df23ae3565 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Fri, 8 Nov 2019 15:39:17 +0800
Subject: [PATCH 7/8] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81?=
=?UTF-8?q?=E8=B0=83=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/messages_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 57a5c7fad..3cbe5287f 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -213,7 +213,7 @@ class MessagesController < ApplicationController
def notify_course_students message, course
course.students.includes(:user).each do |student|
- UserMailer.course_message_email(student&.user&.mail, message.id).deliver_later if student&.user&.mail
+ UserMailer.course_message_email(student&.user&.mail, message.id).deliver_now if student&.user&.mail
end
end
end
From a175a8ac83dadfac351effbb787f7dd2c355c387 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Fri, 8 Nov 2019 15:41:29 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E6=8A=A5=E5=90=8D=E4=BA=BA=E6=95=B0?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/trustie_hacks_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/trustie_hacks_controller.rb b/app/controllers/trustie_hacks_controller.rb
index 0ae56383c..462a5a057 100644
--- a/app/controllers/trustie_hacks_controller.rb
+++ b/app/controllers/trustie_hacks_controller.rb
@@ -15,7 +15,7 @@ class TrustieHacksController < ApplicationController
hacks = hacks.where("name like ?", "%#{search}%")
end
- @hackathon_users_count = hacks ? 0 : hacks.sum(:hack_users_count)
+ @hackathon_users_count = hacks.blank? ? 0 : hacks.sum(:hack_users_count)
@hacks_count = hacks.count
@hacks = hacks.page(page).per(limit)