Skip to content

Commit

Permalink
Fixed the display of error reports, make sure they're in Sydney time.
Browse files Browse the repository at this point in the history
  • Loading branch information
codeka committed Nov 4, 2014
1 parent 0163fd2 commit 2ccfb14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/data/tmpl/admin/debug/error-reports.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h1>Error Reports</h1>
dataTable.addColumn("number", "Empires Reporting");
dataTable.addRows([
{% for entry in error_histogram %}
[new Date({{entry.year}}, {{entry.month}}+1, {{entry.day}}), {{entry.num_client_errors}}, {{entry.num_server_errors}}, {{entry.num_empires_reporting}}],
[new Date({{entry.year}}, {{entry.month}}-1, {{entry.day}}), {{entry.num_client_errors}}, {{entry.num_server_errors}}, {{entry.num_empires_reporting}}],
{% endfor %}
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.TreeMap;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import au.com.codeka.common.Log;
import au.com.codeka.common.protobuf.Messages;
Expand Down Expand Up @@ -114,16 +115,20 @@ protected void get() throws RequestException {

data.put("cursor", cursor);

// TODO: handle more than sydney timezone?
DateTimeZone timeZone = DateTimeZone.forID("Australia/Sydney");
int timeZoneOffset = timeZone.getOffset(DateTime.now());

// add some data so we can display a histogram of the number of errors we're getting
ArrayList<Integer> maxValues = new ArrayList<Integer>();
ArrayList<TreeMap<String, Object>> histogram = new ArrayList<TreeMap<String, Object>>();
sql = "SELECT DATE(report_date) AS date," +
sql = "SELECT DATE(report_date AT TIME ZONE 'Australia/Sydney') AS date," +
" SUM(CASE WHEN empire_id IS NULL THEN 0 ELSE 1 END) AS num_client_errors," +
" SUM(CASE WHEN empire_id IS NULL THEN 1 ELSE 0 END) AS num_server_errors," +
" COUNT(DISTINCT empire_id) AS num_empires_reporting" +
" FROM error_reports" +
" GROUP BY DATE(report_date)" +
" ORDER BY DATE(report_date) DESC" +
" GROUP BY DATE(report_date AT TIME ZONE 'Australia/Sydney')" +
" ORDER BY DATE(report_date AT TIME ZONE 'Australia/Sydney') DESC" +
" LIMIT 60";
try (SqlStmt stmt = DB.prepare(sql)) {
SqlResult res = stmt.select();
Expand Down

0 comments on commit 2ccfb14

Please sign in to comment.