competitions
parent
cb23912b1f
commit
7498740e87
@ -0,0 +1,12 @@
|
||||
json.extract! @competition, :id, :name, :sub_title, :identifier, :bonus, :mode
|
||||
json.visits_count @competition.visits
|
||||
member_count = @competition.team_members.count
|
||||
json.member_count member_count.zero? ? 268 : member_count
|
||||
|
||||
json.start_time @competition.start_time&.strftime("%Y-%m-%d")
|
||||
json.end_time @competition.end_time&.strftime("%Y-%m-%d")
|
||||
json.enroll_end_time @competition.enroll_end_time&.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
json.published @competition.published?
|
||||
json.nearly_published @competition.published_at.present?
|
||||
|
@ -1,36 +1,2 @@
|
||||
competition = current_competition
|
||||
json.extract! competition, :id, :name, :sub_title, :identifier
|
||||
|
||||
json.start_time competition.display_start_time
|
||||
json.end_time competition.display_end_time
|
||||
json.enroll_end_time competition.display_enroll_end_time
|
||||
|
||||
json.images do
|
||||
json.array! competition.attachments, partial: 'attachments/attachment_simple', as: :attachment
|
||||
end
|
||||
|
||||
json.competition_stages do
|
||||
stages = competition.competition_stages.includes(competition_stage_sections: :competition_entries)
|
||||
json.array! stages.each do |stage|
|
||||
json.extract! stage, :id, :name
|
||||
|
||||
json.sections do
|
||||
json.array! stage.competition_stage_sections.each do |section|
|
||||
json.extract! section, :id, :name
|
||||
|
||||
decorator_section = ActiveDecorator::Decorator.instance.decorate(section)
|
||||
json.start_time decorator_section.display_start_time
|
||||
json.end_time decorator_section.display_end_time
|
||||
|
||||
is_start = section.start_time > Time.now
|
||||
json.entries do
|
||||
json.array! section.competition_entries.each do |entry|
|
||||
json.extract! entry, :id, :name
|
||||
|
||||
json.url is_start ? entry.url : ''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
json.extract! @competition, :id, :introduction
|
||||
json.image_url url_to_avatar(@competition)
|
Loading…
Reference in new issue