Skip to content

Commit

Permalink
Stop logging time played globally.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasrosdal committed Sep 13, 2016
1 parent 93078ff commit 0cdd33e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
conn = ds.getConnection();

switch (type) {
case "time": {
String insertTableSQL = "INSERT INTO time_played_stats (statsDate, timePlayed) VALUES (CURDATE(), 2) " +
"ON DUPLICATE KEY UPDATE timePlayed = timePlayed + 2";
PreparedStatement preparedStatement = conn.prepareStatement(insertTableSQL);
preparedStatement.executeUpdate();
break;
}
case "single": {
String insertTableSQL = "INSERT INTO games_played_stats (statsDate, gameType, gameCount) VALUES (CURDATE(), 0, 1) ON DUPLICATE KEY UPDATE gameCount = gameCount + 1";
PreparedStatement preparedStatement = conn.prepareStatement(insertTableSQL);
Expand Down Expand Up @@ -74,9 +67,8 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)


} catch (Exception err) {
response.setHeader("result", "error");
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Error...");
} finally {
System.err.println("Error in FreecivStatsServlet" + err.getMessage());
} finally {
if (conn != null)
try {
conn.close();
Expand Down
2 changes: 1 addition & 1 deletion freeciv-web/src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h3>Latest news from Blog:</h3>
<div class="row">
<div class="col-lg-12">
<center>
<h3><b id="hours_played"></b> hours played globally, <b id="single_count"></b> singleplayer games and <b id="multi_count"></b> multiplayer games.</h3>
<h3><b id="single_count"></b> singleplayer games and <b id="multi_count"></b> multiplayer games.</h3>
<small>Total number of hours played Freeciv-web for all players, number of singleplayer and multiplayer games played for all players globally since 20th February 2016</small>

<br><br><br>
Expand Down
8 changes: 0 additions & 8 deletions freeciv-web/src/main/webapp/javascript/civclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function civclient_init()
control_init();

timeoutTimerId = setInterval(update_timeout, 1000);
statsTimerId = setInterval(update_time_played_stats, 120000);

update_game_status_panel();
statusTimerId = setInterval(update_game_status_panel, 6000);
Expand Down Expand Up @@ -693,10 +692,3 @@ function show_auth_dialog(packet) {


}

/**************************************************************************
Updates the time played statistics.
**************************************************************************/
function update_time_played_stats() {
$.post("/freeciv_time_played_stats?type=time").fail(function() {});
}
3 changes: 1 addition & 2 deletions freeciv-web/src/main/webapp/javascript/frontpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ $(document).ready(function() {
cache: true
}).done(function( game_stats ) {
var stats = game_stats.split(";");
if (stats.length == 4) {
if (stats.length == 3) {
$( "#metalink" ).html("Online Games: " + stats[0]);
$( "#hours_played" ).html(Math.floor((parseFloat(stats[3]))/60));
$( "#single_count" ).html(stats[1]);
$( "#multi_count" ).html(stats[2]);
}
Expand Down
4 changes: 1 addition & 3 deletions freeciv-web/src/main/webapp/meta/fpinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
fcdb_metaserver_connect();
}

$stmt = "select (select count(*) from servers where state = 'Running') as running_count, (select SUM(gameCount) from games_played_stats where gametype = 0) as single_count, (select SUM(gameCount) from games_played_stats where gametype IN (1, 2)) as multi_count, (select SUM(timePlayed) from time_played_stats) as minutes_played";
$stmt = "select (select count(*) from servers where state = 'Running') as running_count, (select SUM(gameCount) from games_played_stats where gametype = 0) as single_count, (select SUM(gameCount) from games_played_stats where gametype IN (1, 2)) as multi_count";
$res = fcdb_exec($stmt);
$row = fcdb_fetch_next_row($res, 0);
print db2html($row["running_count"]);
print(";");
print db2html($row["single_count"]);
print(";");
print db2html($row["multi_count"]);
print(";");
print db2html($row["minutes_played"]);
?>

0 comments on commit 0cdd33e

Please sign in to comment.