add: competitions
This commit is contained in:
parent
b81d92af46
commit
0a00a4bc0e
|
@ -0,0 +1,9 @@
|
||||||
|
class Home::CompetitionsController < ApplicationController
|
||||||
|
|
||||||
|
def index
|
||||||
|
@competitions = Competition.active.order(start_time: :desc).limit(3)
|
||||||
|
if @competitions.size < 3
|
||||||
|
@competitions += Competition.archived.order(start_time: :desc).limit(3-@competitions.size)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
class PlatformStatisticsController < ApplicationController
|
class Home::PlatformStatisticsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@platform_statistic = PlatformStatistic.data
|
@platform_statistic = PlatformStatistic.data
|
|
@ -0,0 +1,4 @@
|
||||||
|
class Competition < ApplicationRecord
|
||||||
|
|
||||||
|
enum status: {archived: 0, active: 1}
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
json.competitions do
|
||||||
|
json.array! @competitions.each do |competition|
|
||||||
|
json.(competition, :id, :title, :content)
|
||||||
|
json.start_time format_time(competition.start_time)
|
||||||
|
json.end_time format_time(competition.end_time)
|
||||||
|
end
|
||||||
|
end
|
|
@ -102,7 +102,10 @@ Rails.application.routes.draw do
|
||||||
get :template_file
|
get :template_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :platform_statistics, only: [:index]
|
namespace :home do
|
||||||
|
resources :platform_statistics, only: [:index]
|
||||||
|
resources :competitions, only:[:index]
|
||||||
|
end
|
||||||
get 'home/index'
|
get 'home/index'
|
||||||
get 'home/search'
|
get 'home/search'
|
||||||
get 'main/first_stamp'
|
get 'main/first_stamp'
|
||||||
|
|
Loading…
Reference in New Issue