Improve gather archive

This commit is contained in:
Ari Timonen 2020-03-26 20:50:14 +02:00
parent fa7c32c507
commit dcac8e067a
4 changed files with 32 additions and 10 deletions

View file

@ -3,7 +3,7 @@ class GathersController < ApplicationController
respond_to :html, :js
def index
@gathers = Gather.ordered.limit(50).all
@gathers = Gather.ordered.limit(50).all.paginate(per_page: 40, page: params[:page])
end
def show

View file

@ -41,7 +41,7 @@ class Gather < ActiveRecord::Base
scope :basic, -> { includes(:captain1, :captain2, :map1, :map2, :server) }
scope :active, -> { where("gathers.status IN (?, ?, ?) AND gathers.updated_at > ?",
STATE_VOTING, STATE_PICKING, STATE_RUNNING, 12.hours.ago.utc) }
belongs_to :server, :optional => true
belongs_to :captain1, :class_name => "Gatherer", :optional => true
belongs_to :captain2, :class_name => "Gatherer", :optional => true

View file

@ -23,12 +23,18 @@
<a href="javascript:" id="gatherJoinBtn" class="button">
Click to join gather!
</a>
<%= link_to gathers_path(), class: 'button' do %>
Gather archive
<% end %>
</a>
</p>
<% end %>
<% else %>
<p>Log in to join the gather.</p>
<%= link_to gathers_path(), class: 'button tiny' do %>
Gather archive
<% end %>
<% end %>
<% elsif @gather.status == Gather::STATE_VOTING %>
@ -60,11 +66,14 @@
<% end %>
</p>
<p>
<% if @gather.server and @gather.server.ip and @gather.server.password %>
<p>
<%= link_to "Click to join Server", "steam://run/4920//connect #{@gather.server.ip} #{@gather.server.password}", class: 'join button tiny' %>
</p>
<%= link_to "Click to join Server", "steam://run/4920//connect #{@gather.server.ip} #{@gather.server.password}", class: 'join button tiny' %>
<% end %>
<%= link_to gathers_path(), class: 'button tiny' do %>
Gather archive
<% end %>
</p>
<% end %>

View file

@ -1,19 +1,30 @@
<h1>Gather Archive</h1>
<h5 class="title">Players starred were captains for their respective teams.</h5>
<%= will_paginate @gathers %>
<table class="gathers striped">
<tr>
<th class="date">Date</th>
<th class="info">Info</th>
<th class="team1">Team 1</th>
<th class="team2">Team 2</th>
</tr>
<% @gathers.each do |gather| %>
<tr class="<%= cycle('even', 'odd') %>">
<td><%= link_to gather.updated_at.strftime("%Y/%m/%d %H:%M:%S"), gather %></td>
<td>
<p>
<%= link_to gather.updated_at.strftime("%Y/%m/%d %H:%M:%S"), gather %>
</p>
<p>
<%= namelink gather&.map1&.map %>
<%= namelink gather&.map2&.map %>
</p>
</td>
<td>
<ul>
<% gather.gatherers.each do |gatherer| %>
<% gather.gatherers.ordered.each do |gatherer| %>
<li>
<% if gatherer.team == 1 %>
<%= link_to gatherer.user.to_s, User.find_by_username(gatherer.user.to_s) %>
@ -27,7 +38,7 @@
</td>
<td>
<ul>
<% gather.gatherers.each do |gatherer| %>
<% gather.gatherers.ordered.each do |gatherer| %>
<li>
<% if gatherer.team == 2 %>
<%= link_to gatherer.user.to_s, User.find_by_username(gatherer.user.to_s) %>
@ -42,3 +53,5 @@
</tr>
<% end %>
</table>
<%= will_paginate @gathers %>