Permalink
Browse files

snapshot.

  • Loading branch information...
1 parent 4ac8a58 commit 2ca90092c20e6680fd28a80debdaad5f30594ef9 @mfine mfine committed Apr 12, 2012
@@ -2,7 +2,7 @@
up do
create_table(:players) do
primary_key :id
- String :user
+ column :user, "text", unique: true
end
end
@@ -2,10 +2,12 @@
up do
create_table(:results) do
primary_key :id
- Integer :winner_id
- Integer :loser_id
+ column :at, DateTime
+ column :winner_id, "integer"
+ column :loser_id, "integer"
end
end
+
down do
drop_table(:results)
end
View
@@ -1,5 +1,3 @@
-require "sequel"
-require "queue_classic"
require "irb"
require "task"
View
@@ -3,6 +3,8 @@
require "sinatra"
require "sinatra/google-auth"
+require "ranked/ranking"
+
module Ranked
class Api < Sinatra::Base
register Sinatra::GoogleAuth
@@ -24,16 +26,19 @@ def data
get "/" do
authenticate
+ @players = Ranking.ladder
haml :index
end
get "/players" do
authenticate
+ @players = Player.all
haml :players
end
get "/results" do
authenticate
+ @results = Result.all
haml :results
end
View
@@ -1,5 +1,5 @@
module Ranked
- autoload :User, "ranked/user"
- autoload :Event, "ranked/event"
+ autoload :Player, "ranked/player"
+ autoload :Result, "ranked/result"
end
View
@@ -1,4 +1,12 @@
module Ranked
class Result < Sequel::Model
+
+ def winner_user
+ Player[winner_id].user
+ end
+
+ def loser_user
+ Player[loser_id].user
+ end
end
end
View
@@ -1,5 +1,10 @@
.container
- %h1
- Bootstrap starter template
- %p
- Use this document as a way to quick start any new project.<br> All you get is this message and a barebones HTML document.
+
+%table.table.table-condensed.table-striped
+ %thead
+ %tr
+ %th User
+ %tbody
+ - @players.each do |player|
+ %tr
+ %td= player.user
View
@@ -1,5 +1,10 @@
.container
- %h1
- Bootstrap starter template
- %p
- Use this document as a way to quick start any new project.<br> All you get is this message and a barebones HTML document.
+
+%table.table.table-condensed.table-striped
+ %thead
+ %tr
+ %th User
+ %tbody
+ - @players.each do |player|
+ %tr
+ %td= player.user
View
@@ -1,5 +1,14 @@
.container
- %h1
- Bootstrap starter template
- %p
- Use this document as a way to quick start any new project.<br> All you get is this message and a barebones HTML document.
+
+%table.table.table-condensed.table-striped
+ %thead
+ %tr
+ %th At
+ %th Winner
+ %th Loser
+ %tbody
+ - @results.each do |result|
+ %tr
+ %td= result.at
+ %td= result.winner_user
+ %td= result.loser_user

0 comments on commit 2ca9009

Please sign in to comment.