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 respond_to :html, :js
def index def index
@gathers = Gather.ordered.limit(50).all @gathers = Gather.ordered.limit(50).all.paginate(per_page: 40, page: params[:page])
end end
def show def show

View file

@ -41,7 +41,7 @@ class Gather < ActiveRecord::Base
scope :basic, -> { includes(:captain1, :captain2, :map1, :map2, :server) } scope :basic, -> { includes(:captain1, :captain2, :map1, :map2, :server) }
scope :active, -> { where("gathers.status IN (?, ?, ?) AND gathers.updated_at > ?", scope :active, -> { where("gathers.status IN (?, ?, ?) AND gathers.updated_at > ?",
STATE_VOTING, STATE_PICKING, STATE_RUNNING, 12.hours.ago.utc) } STATE_VOTING, STATE_PICKING, STATE_RUNNING, 12.hours.ago.utc) }
belongs_to :server, :optional => true belongs_to :server, :optional => true
belongs_to :captain1, :class_name => "Gatherer", :optional => true belongs_to :captain1, :class_name => "Gatherer", :optional => true
belongs_to :captain2, :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"> <a href="javascript:" id="gatherJoinBtn" class="button">
Click to join gather! Click to join gather!
</a> </a>
<%= link_to gathers_path(), class: 'button' do %>
Gather archive
<% end %>
</a>
</p> </p>
<% end %> <% end %>
<% else %> <% else %>
<p>Log in to join the gather.</p> <p>Log in to join the gather.</p>
<%= link_to gathers_path(), class: 'button tiny' do %>
Gather archive
<% end %>
<% end %> <% end %>
<% elsif @gather.status == Gather::STATE_VOTING %> <% elsif @gather.status == Gather::STATE_VOTING %>
@ -60,11 +66,14 @@
<% end %> <% end %>
</p> </p>
<p>
<% if @gather.server and @gather.server.ip and @gather.server.password %> <% 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' %>
<%= link_to "Click to join Server", "steam://run/4920//connect #{@gather.server.ip} #{@gather.server.password}", class: 'join button tiny' %>
</p>
<% end %> <% end %>
<%= link_to gathers_path(), class: 'button tiny' do %>
Gather archive
<% end %>
</p>
<% end %> <% end %>

View file

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