Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
86 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
*.bak | ||
*.out | ||
|
||
tmp | ||
|
||
# rubyweb | ||
|
||
rubyweb/public/assets/*.css | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
|
||
class HomeController < ApplicationController | ||
require 'sqlite3' | ||
@@db = SQLite3::Database.new '../tmp/game.db' | ||
|
||
def index | ||
@replays = Replay.recent.limit(5) | ||
end | ||
|
||
def scoreboard | ||
@dailys = @@db.execute('select * from (select name, count(*) as count from scores where time > ? group by name) order by count desc limit 10', Date.today.to_time.to_f) | ||
@weeklys = @@db.execute('select * from (select name, count(*) as count from scores where time > ? group by name) order by count desc limit 10', (Date.today - 7.days).to_time.to_f) | ||
@monthlys = @@db.execute('select * from (select name, count(*) as count from scores where time > ? group by name) order by count desc limit 10', (Date.today - 30.days).to_time.to_f) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#place | ||
#scoreboard | ||
- for name, data in [['daily', @dailys], ['weekly', @weeklys], ['monthly', @monthlys]] | ||
%table{border: "1", cellpadding: "2", cellspacing: "2", class: name} | ||
%tr | ||
%th{COLSPAN: "2"}= "#{name} score" | ||
|
||
- for name, count in data | ||
%tr | ||
%td.name= name | ||
%td.score= count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ | |
|
||
devise_for :users | ||
|
||
match ':controller(/:action(/:id(.:format)))' | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env python | ||
#-*- coding:utf-8 -*- | ||
""" | ||
module: db | ||
""" | ||
import sqlite3 | ||
db = sqlite3.connect('tmp/game.db') | ||
cursor = db.cursor() | ||
try: | ||
cursor.execute('create table scores (time, name)') | ||
except: | ||
pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this dir is for temp files |