From dcac8e067a15d72318039a60451c3da8dc0fcd58 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Thu, 26 Mar 2020 20:50:14 +0200 Subject: [PATCH] Improve gather archive --- app/controllers/gathers_controller.rb | 2 +- app/models/gather.rb | 2 +- app/views/gathers/_status.html.erb | 17 +++++++++++++---- app/views/gathers/index.html.erb | 21 +++++++++++++++++---- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/controllers/gathers_controller.rb b/app/controllers/gathers_controller.rb index 0703678..fe58618 100644 --- a/app/controllers/gathers_controller.rb +++ b/app/controllers/gathers_controller.rb @@ -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 diff --git a/app/models/gather.rb b/app/models/gather.rb index 4c55596..4c623cf 100644 --- a/app/models/gather.rb +++ b/app/models/gather.rb @@ -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 diff --git a/app/views/gathers/_status.html.erb b/app/views/gathers/_status.html.erb index 4b0e67c..76be786 100644 --- a/app/views/gathers/_status.html.erb +++ b/app/views/gathers/_status.html.erb @@ -23,12 +23,18 @@ Click to join gather! + <%= link_to gathers_path(), class: 'button' do %> + Gather archive + <% end %> +

<% end %> <% else %>

Log in to join the gather.

- + <%= link_to gathers_path(), class: 'button tiny' do %> + Gather archive + <% end %> <% end %> <% elsif @gather.status == Gather::STATE_VOTING %> @@ -60,11 +66,14 @@ <% end %>

+

<% if @gather.server and @gather.server.ip and @gather.server.password %> -

- <%= 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' %> <% end %> + <%= link_to gathers_path(), class: 'button tiny' do %> + Gather archive + <% end %> +

<% end %> diff --git a/app/views/gathers/index.html.erb b/app/views/gathers/index.html.erb index e4d205d..0f3bbdb 100644 --- a/app/views/gathers/index.html.erb +++ b/app/views/gathers/index.html.erb @@ -1,19 +1,30 @@

Gather Archive

Players starred were captains for their respective teams.
+ +<%= will_paginate @gathers %> + - + <% @gathers.each do |gather| %> - + <% end %>
DateInfo Team 1 Team 2
<%= link_to gather.updated_at.strftime("%Y/%m/%d %H:%M:%S"), gather %> +

+ <%= link_to gather.updated_at.strftime("%Y/%m/%d %H:%M:%S"), gather %> +

+

+ <%= namelink gather&.map1&.map %> + <%= namelink gather&.map2&.map %> +

+
    - <% gather.gatherers.each do |gatherer| %> + <% gather.gatherers.ordered.each do |gatherer| %>
  • <% if gatherer.team == 1 %> <%= link_to gatherer.user.to_s, User.find_by_username(gatherer.user.to_s) %> @@ -27,7 +38,7 @@
    - <% gather.gatherers.each do |gatherer| %> + <% gather.gatherers.ordered.each do |gatherer| %>
  • <% if gatherer.team == 2 %> <%= link_to gatherer.user.to_s, User.find_by_username(gatherer.user.to_s) %> @@ -42,3 +53,5 @@
+ +<%= will_paginate @gathers %> \ No newline at end of file