Permalink
Browse files

🐬 Cleanup and fixes #39.

* Recover from db crashes.
* Shortcuts for better scripts and cron jobs.
* Consolidated robot name display.
* Added trophy for contributors.
  • Loading branch information...
WhiteHalmos committed Apr 12, 2016
1 parent d13eca8 commit f0b5dfe0368fbb2fe21dfcfb6d191fe75f1a0692
View
@@ -0,0 +1,7 @@
#!/usr/bin/bash
alias dkc=docker-compose
alias dkcupd='dkc up -d'
alias dkcstop='dkc stop'
alias dkcrmall='dkc rm -v -f db matchmaker webapp server run'
alias dkcrestart='dkcstop && dkcrmall && dkcupd'
View
@@ -263,8 +263,8 @@ def run_ranked_match(db, match):
def main():
BATCH = 1000
REST = 60
PER_REST = 5
REST = 15 * 60
PER_REST = 15
def lap():
global t
View
@@ -12,7 +12,7 @@
import rgkit.game
import tools
S_MATCH_REST = 4.0
S_MATCH_REST = 2.0
TIME_RATE = 0.1
WIN_RATE = 0.05
View
@@ -2,14 +2,16 @@
# Run sql
export PATH="/usr/local/bin:$PATH"
echo 'SQL'
docker-compose run --no-deps -e PGOPTIONS='--client-min-messages=warning' --entrypoint psql run -h db -U robot -d robotgame -q -1 -f /sql/daily.sql
docker-compose run --rm --no-deps -e PGOPTIONS='--client-min-messages=warning' --entrypoint psql run -h db -U robot -d robotgame -q -1 -f /sql/daily.sql
# Backup dbs
echo 'Backup dbs'
docker-compose run --no-deps --entrypoint pg_dump run -h db -U robot -d robotgame --format=c -s -f /dbbackups/`date +\%Y-\%m-\%d`-robotgame-schema
docker-compose run --no-deps --entrypoint pg_dump run -h db -U robot -d robotgame --format=c -a -T history -f /dbbackups/`date +\%Y-\%m-\%d`-robotgame-data
docker-compose run --rm --no-deps --entrypoint pg_dump run -h db -U robot -d robotgame --format=c -s -f /dbbackups/`date +\%Y-\%m-\%d`-robotgame-schema
docker-compose run --rm --no-deps --entrypoint pg_dump run -h db -U robot -d robotgame --format=c -a -T history -f /dbbackups/`date +\%Y-\%m-\%d`-robotgame-data
# Retore dbs
#docker-compose run --rm --no-deps --entrypoint pg_restore run -h db -U robot -d robotgame --format=c -a /dbbackups/restoredata
# Compress matches
# Note that -mtime +1 matches at least 2 days ago
# Keep for 2 weeks so fewer 404s for Google
echo 'Clean matchlog'
docker-compose run --no-deps --entrypoint find run /matchlog/ -not -path "/matchlog/" -not -path "*/.gitkeep" -mtime +13 -delete;
docker-compose run --rm --no-deps --entrypoint find run /matchlog/ -not -path "/matchlog/" -not -path "*/.gitkeep" -mtime +13 -delete;
echo 'Done'
View
@@ -1,2 +1,2 @@
#!/bin/bash
docker-compose run --entrypoint psql run -h db -U robot -d robotgame
exec docker-compose run --rm --no-deps --entrypoint psql run -h db -U robot -d robotgame
View
@@ -1,2 +1,3 @@
update users set challenges=0;
update robots set last_rating=rating where rating is not NULL;
update robots set disabled=true where not automatch and not disabled and compiled and passed;
View
@@ -2622,6 +2622,9 @@ abbr {
.trophy-short {
color: peru;
}
.trophy-contributor {
color: gold;
}
.chart {
width: 228px;
@@ -86,32 +86,14 @@
<div class="rating-diff" rel="tooltip" title="$tplib.rating_diff(robot)">
<i class="fa $tplib.rating_diff_class(robot)"></i>
</div>
$if 'logged_in' in sess and sess['user_id'] == robot.user_id:
$ color_class = 'me'
$ exp = 'My own bot'
$elif tplib.timedelta_ago(robot.last_updated).days < 3:
$ color_class = 'fresh'
$elif robot.automatch:
$ color_class = 'automatch'
$else:
$ color_class = ''
<div>
<a class="name $color_class" href="/robot/$robot.id">
$robot.name
</a>
$if robot.fast:
<i class="fa fa-tachometer trophy-fast" rel="tooltip" title="Fast bot trophy."></i>
$if robot.short:
<i class="fa fa-suitcase trophy-short" rel="tooltip" title="Short bot trophy."></i>
$:tplib.fancy_display_name(robot)
</div>
$if tplib.is_mod(sess):
<div>
$tplib.rounded(100 * robot.winrate)%
</div>
<div class="open-source last defcursor faded">
$if not os and robot.open_source:
<i class="fa fa-github faded" rel="tooltip" title="This robot is open-source!"></i>
</div>
<div class="last"></div>
</div>
</div>
$if len(robots) == 0:
View
@@ -76,6 +76,24 @@ <h1 class='score'></h1>-->
</div>
</div>
$if tplib.is_logged_in(sess):
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="EKWJ8ELN3359Y">
<input type="hidden" name="on1" value="User ID">
<input type="hidden" name="os1" maxlength="200" value="$(sess.user_id)">
<table>
<tr><td><input type="hidden" name="on0" value="Donate to Support Robot Game">Donate to Support Robot Game</td></tr><tr><td><select name="os0">
<option value="Silver">Silver : $$5.00 USD - monthly</option>
<option value="Gold">Gold : $$10.00 USD - monthly</option>
<option value="Bronze">Bronze : $$2.00 USD - monthly</option>
</select> </td></tr>
<tr><td><input type="hidden" name="on2" value="Email"><input type="text" name="os2" maxlength="200" placeholder="Email (optional)"></td></tr>
</table>
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<br />
<div class="g-post" data-href="https://plus.google.com/109162859755475455960/posts/fJHQ5nKV82X"></div>
<script src="https://apis.google.com/js/plusone.js"></script>
</div>
@@ -3,21 +3,7 @@
<div class="clearfix">
<div class="left">
<h1 class="no-margin">
$if tplib.timedelta_ago(robot.last_updated).days < 3:
$ color_class = 'fresh'
$elif robot.automatch:
$ color_class = 'automatch'
$else:
$ color_class = ''
<a class="name $color_class" href="/robot/$robot.id">
$robot.name
</a>
$if robot.fast:
<i class="fa fa-tachometer trophy-fast" rel="tooltip" title="Fast bot trophy."></i>
$if robot.short:
<i class="fa fa-suitcase trophy-short" rel="tooltip" title="Short bot trophy."></i>
$if robot.open_source:
<i class="fa fa-github faded" rel="tooltip" title="Open-source."></i>
$:tplib.fancy_display_name(robot)
</h1>
<div class="faded">
<div>Elo rating: $:tplib.drating(robot, decimal=True)</div>
@@ -3,21 +3,7 @@
<div class="clearfix">
<div class="left">
<h1 class="no-margin">
$if tplib.timedelta_ago(robot.last_updated).days < 3:
$ color_class = 'fresh'
$elif robot.automatch:
$ color_class = 'automatch'
$else:
$ color_class = ''
<a class="name $color_class" href="/robot/$robot.id">
$robot.name
</a>
$if robot.fast:
<i class="fa fa-tachometer trophy-fast" rel="tooltip" title="Fast bot trophy."></i>
$if robot.short:
<i class="fa fa-suitcase trophy-short" rel="tooltip" title="Short bot trophy."></i>
$if robot.open_source:
<i class="fa fa-github faded" rel="tooltip" title="Open-source."></i>
$:tplib.fancy_display_name(robot)
</h1>
<div class="faded">
<div>Elo rating: $:tplib.drating(robot, decimal=True)</div>
@@ -18,13 +18,7 @@ <h1>Robots</h1>
$for robot in robots:
<p>
<div class="large">
<a href="/robot/$robot.id">$robot.name</a>
$if robot.fast:
<i class="fa fa-tachometer trophy-fast" rel="tooltip" title="Fast bot trophy."></i>
$if robot.short:
<i class="fa fa-suitcase trophy-short" rel="tooltip" title="Short bot trophy."></i>
$if robot.open_source:
<i class="fa fa-github faded" rel="tooltip" title="This robot is open-source!"></i>
$:tplib.fancy_display_name(robot)
</div>
<div class="faded">
Elo rating: $:tplib.drating(robot)<br/>
@@ -3,21 +3,7 @@
<div class="clearfix">
<div class="left">
<h1 class="no-margin">
$if tplib.timedelta_ago(robot.last_updated).days < 3:
$ color_class = 'fresh'
$elif robot.automatch:
$ color_class = 'automatch'
$else:
$ color_class = ''
<a class="name $color_class" href="/robot/$robot.id">
$robot.name
</a>
$if robot.fast:
<i class="fa fa-tachometer trophy-fast" rel="tooltip" title="Fast bot trophy."></i>
$if robot.short:
<i class="fa fa-suitcase trophy-short" rel="tooltip" title="Short bot trophy."></i>
$if robot.open_source:
<i class="fa fa-github faded" rel="tooltip" title="Open-source."></i>
$:tplib.fancy_display_name(robot)
</h1>
<div class="faded">
<div>Elo rating: $:tplib.drating(robot, decimal=True)</div>
@@ -31,13 +31,7 @@ <h1>Robots</h1>
$for robot in robots:
<p>
<div class="large">
<a href="/robot/$robot.id">$robot.name</a>
$if robot.fast:
<i class="fa fa-tachometer trophy-fast" rel="tooltip" title="Fast bot trophy."></i>
$if robot.short:
<i class="fa fa-suitcase trophy-short" rel="tooltip" title="Short bot trophy."></i>
$if robot.open_source:
<i class="fa fa-github faded" rel="tooltip" title="This robot is open-source!"></i>
$:tplib.fancy_display_name(robot)
</div>
<div class="faded">
Elo rating: $:tplib.drating(robot)<br/>
View
@@ -9,11 +9,13 @@
1, # bh (hehe, just use one account to be safe
)
MODERATORS = (
7392, # WhiteHalmos
1, # bh
2840 # aurick
2840, # aurick
)
CONTRIBUTORS = (
#7392, # WhiteHalmos
5192, # Sh4rk
)
USER_SALT = 'bbiuyxzoswekl;jgtohgoaboih'
def is_mod(sess):
@@ -213,3 +215,24 @@ def safe_markdown(string):
string = markdown.markdown(string)
others = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']
return bleach.clean(string, tags=bleach.ALLOWED_TAGS + others)
def fancy_display_name(robot):
if timedelta_ago(robot.last_updated).days < 3:
color = 'fresh'
elif robot.automatch:
color = 'automatch'
else:
color = ''
res = '''<a class="name {0}" href="/robot/{1}">
{2}
</a>'''.format(color, robot.id, robot.name)
if robot.fast:
res += '\n<i class="fa fa-tachometer trophy-fast" rel="tooltip" title="Fast bot trophy."></i>'
if robot.short:
res += '\n<i class="fa fa-suitcase trophy-short" rel="tooltip" title="Short bot trophy."></i>'
if robot.open_source:
res += '\n<i class="fa fa-github faded" rel="tooltip" title="Open-source."></i>'
if robot.user_id and robot.user_id in CONTRIBUTORS:
res += '\n<i class="fa fa-star trophy-contributor" rel="tooltip" title="Robot Game supporter, thank you!"></i>'
return res

0 comments on commit f0b5dfe

Please sign in to comment.