diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index ea09b9003..e54d5c34f 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -40,10 +40,8 @@ class GamesController < ApplicationController next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) # 关卡点赞数, praise_or_tread = 1则表示赞过 - praise_count = PraiseTread.where(praise_tread_object_id: game_challenge.id, praise_tread_object_type: "Challenge", - praise_or_tread: 1).count - user_praise = PraiseTread.where(praise_tread_object_id: game_challenge.id, praise_tread_object_type: "Challenge", - user_id: current_user.id, praise_or_tread: 1).present? ? true : false + praise_count = game_challenge.praises_count + user_praise = game_challenge.praise_tread.exists?(user_id:current_user.id, praise_or_tread: 1) # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 max_query_index = @game.query_index.to_i