jweigelt / swbf2admin

Star Wars Battlefront II (2005) server management application
GNU General Public License v3.0
51 stars 18 forks source link

Statistics: Can't View | Index was outside the bounds of the array. #36

Closed msmcpeake closed 4 years ago

msmcpeake commented 4 years ago

Loving this tool! Unfortunately, when I refresh the statistics page I get the following error:

[5/23/2020 6:06:29 PM] DEBUG | [WEB] Got request 'http://192.168.1.105:8080/db/statistics' [5/23/2020 6:06:29 PM] | [SQL] Query: SELECT * FROM prefix_stats_games WHERE game_started_timestamp > @from_timestamp AND game_started_timestamp < @until_timestamp AND game_ended_timestamp > 0 ORDER BY game_started_timestamp DESC LIMIT @page,@max_rows [5/23/2020 6:06:29 PM] ERROR | [WEB] WebAdmin error(System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Data.SQLite.SQLiteDataReader.GetSQLiteType(SQLiteConnectionFlags flags, Int32 i) at System.Data.SQLite.SQLiteDataReader.GetValue(Int32 i) at System.Data.SQLite.SQLiteDataReader.get_Item(String name) at SWBF2Admin.Database.SQLHandler.RI(DbDataReader reader, String field) at SWBF2Admin.Database.SQLHandler.ReadMatch(DbDataReader reader) at SWBF2Admin.Database.SQLHandler.GetMatches(String nameExp, String mapExp, Boolean onlySelected, DateTime dateFrom, DateTime dateUntil, Int32 page, Int32 maxRows) at SWBF2Admin.Web.Pages.StatisticsPage.HandlePost(HttpListenerContext ctx, WebUser user, String postData) at SWBF2Admin.Web.Pages.AjaxPage.HandleContext(HttpListenerContext ctx, WebUser user) at SWBF2Admin.Web.WebServer.HandleContext(HttpListenerContext ctx))

I have Game Statistics and Player Statistics gathering enabled and verified there is data in SQL.

msmcpeake commented 4 years ago

It seems you have put "SELECT FROM prefix_stats_games" instead of "SELECT FROM swbf_stats_games" unless I am mistaken.

jweigelt commented 4 years ago

I apparently uploaded an older sqlite db along with the release, sorry. The old db is unfortunately missing two table columns. I updated the db in the current release so new downloads should no longer experience this issue. To patch the current database, add the following columns to swbf_stats_games:

TEXT game_name
INT game_selected

or run something like

ALTER TABLE `swbf_stats_games` ADD COLUMN game_name TEXT;
ALTER TABLE `swbf_stats_games` ADD COLUMN game_selected INTEGER;

I'll also add some code to patch the db automatically in future releases. Thank you for the detailed report!

msmcpeake commented 4 years ago

Thanks! It now shows data in the panel.

Also, in your readme, it says

if you want to track player statistics as well, open ./cfg/players.xml, set
<EnablePlayerStatsLogging>false</EnablePlayerStatsLogging>

Is that a typo, or do I need to set it to false to see player statistics? I have it set to true in players.xml

jweigelt commented 4 years ago

You are correct, EnablePlayerStatsLogging has to be set to true. I fixed the typo in 17d27c5a8b4c70eb5a68e7ef01b7365482c4fcf4.

msmcpeake commented 4 years ago

Could there possibly be a feature in the future for player stats history? Total kills, deaths, etc per username? Thanks for all the help!

jweigelt commented 4 years ago

There is an ingame !stats command that prints out all time statistics for a single player. Advanced statistics via web admin might be added at some point, although adding new features is not really a priority at the moment.