2 Commitit be735c5c78 ... 8e09a28ecb

Tekijä SHA1 Viesti Päivämäärä
  scuti 8e09a28ecb generates page for fastest players 1 kuukausi sitten
  scuti 1c2d153870 added query for platest player for a given map 1 kuukausi sitten
4 muutettua tiedostoa jossa 31 lisäystä ja 7 poistoa
  1. 5 0
      queries/fastest-player-of-map.sql
  2. 1 1
      queries/fastest-players.sql
  3. 6 1
      scripts/allmaps.py
  4. 19 5
      src/dbquery.c

+ 5 - 0
queries/fastest-player-of-map.sql

@@ -0,0 +1,5 @@
+select speed, ifnull(alias, 'Unregistered Player')
+from Speed, Fastest_players
+left join Id2alias
+    on idvalue = cryptokey
+where Speed.mapid = Fastest_players. mapid and Speed.mapid = ?

+ 1 - 1
queries/fastest-players.sql

@@ -1,4 +1,4 @@
-select Speed.mapid, speed, alias
+select Speed.mapid, speed, ifnull(alias, 'Unregistered Player')
 from Speed, Fastest_players
 left join Id2alias
 on Fastest_players.idvalue = cryptokey

+ 6 - 1
scripts/allmaps.py

@@ -34,7 +34,12 @@ def main():
     template = ""
     with open("overview.html", 'r') as fin:
         template = fin.read()
-    renderindex(template)
+        renderindex(template)
+        # speed records uses something similar
+        query = {"QUERY_STRING" : "fastest-players"}
+        table = getcontent(query)
+        with open("output/fastest-players.html", 'w') as fout:
+            fout.write(template % table)
     maps  = getmaps("db/cts.db")
     with open("map.html", 'r') as fin:
         template = fin.read()

+ 19 - 5
src/dbquery.c

@@ -5,9 +5,10 @@
 #include <sqlite3.h>
 #include "colors.h"
 
-#define QOVERVIEW 'o'
-#define QRPLAYER 'p'
-#define QMLEADERBOARD 'm'
+#define QOVERVIEW 'o'       // default case - see get_filename()
+#define QRPLAYER 'p'        // ?player=
+#define QMLEADERBOARD 'm'   // ?map=
+#define QFASTEST 'f'
 
 static inline char *get_filename(char * const c) {
     char *qout = "queries/mranks.sql"; 
@@ -22,6 +23,9 @@ static inline char *get_filename(char * const c) {
             case QRPLAYER:
                 qout = "queries/rplayers.sql";
                 break;
+            case QFASTEST:
+                qout = "queries/fastest-players.sql";
+                break;
         }
     }
     return qout;
@@ -58,6 +62,14 @@ static inline void print_tblheader(const char *c) {
                  <TH class='columnname'>Rank</TH>\
                  </TR>";
             break;
+        case QFASTEST:
+            labels = "<table class='leaderboard'>\
+             <th class='tablename' COLSPAN='3'>Map List</th>\
+             <tr>\
+             <th class='columnname'>Name</th>\
+             <th class='columnname'>Highest Velocty (qu/s)</th>\
+             <th class='columnname'>Held By</th>\
+             </tr>";
     }
     printf("%s", labels);
 }
@@ -84,9 +96,11 @@ static void print_time(const unsigned char *strcs) {
 static void qresult(sqlite3_stmt * const sp, const char *c) {
 #define ISPLAYERNAME(x, y) (y == 1 && *x == QMLEADERBOARD) || \
                            (y == 3 && *x == QOVERVIEW)|| \
-                           (y == 0 && *x == QRPLAYER)
+                           (y == 0 && *x == QRPLAYER) || \
+                           (y == 2 && *x == QFASTEST)
 #define ISMAPNAME(x, y) (y == 0 && *x == QOVERVIEW) ||\
-                        (y == 1 && *x == QRPLAYER)
+                        (y == 1 && *x == QRPLAYER) || \
+                        (y == 0 && *x == QFASTEST)
     int e;
     unsigned int i;
     const unsigned int cc  = sqlite3_column_count(sp);