parent
310a628363
commit
3e68b5a652
@ -1,3 +1,4 @@
|
|||||||
class HackUserCode < ApplicationRecord
|
class HackUserCode < ApplicationRecord
|
||||||
# 用户编程题的信息
|
# 用户编程题的信息
|
||||||
|
belongs_to :hack
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
class HackUserLastestCode < ApplicationRecord
|
class HackUserLastestCode < ApplicationRecord
|
||||||
# 编程题最新代码
|
# 编程题最新代码
|
||||||
|
belongs_to :hack, counter_cache: true
|
||||||
|
|
||||||
|
scope :mine, ->(author_id){ where(user_id: author_id)}
|
||||||
|
scope :passed, -> {where(status: 1)}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
json.top_data do
|
||||||
|
json.passed_count @pass_count
|
||||||
|
json.simple_count @simple_count
|
||||||
|
json.medium_count @medium_count
|
||||||
|
json.diff_count @diff_count
|
||||||
|
end
|
||||||
|
|
||||||
|
json.hacks_count @hacks_count
|
||||||
|
json.hacks_list do
|
||||||
|
json.array! @hacks do |hack|
|
||||||
|
json.(hack,:identifier, :name , :hack_user_lastest_codes_count, :difficult, :passed_rate, :category)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,11 @@
|
|||||||
|
class AddStatusEndTimeForHackUserLastestCode < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :hack_user_lastest_codes, :passed, :boolean, :default => false
|
||||||
|
add_column :hack_user_lastest_codes, :pass_time, :timestamp
|
||||||
|
add_column :hack_user_lastest_codes, :status, :integer, :default => 0
|
||||||
|
add_column :hacks, :hack_user_lastest_codes_count, :integer, :default => 0
|
||||||
|
add_column :hacks, :pass_num, :integer, :default => 0
|
||||||
|
add_index :hack_user_lastest_codes, :user_id, name: "user_index"
|
||||||
|
add_index :hack_user_lastest_codes, :hack_id, name: "hack_index"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue