aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/Core/Stats.pm
diff options
context:
space:
mode:
authorDarkelarious <darkelarious@333networks.com>2016-11-19 20:56:04 +0100
committerDarkelarious <darkelarious@333networks.com>2016-11-19 20:56:04 +0100
commitc3f8d65a4fb1f5674557ee67cf7f74369df86ad1 (patch)
tree92aab2a394bda28da0ed7c7c75e633fdf386fc71 /lib/MasterServer/Core/Stats.pm
parent1de3da4b8027508a91144639455c934fd6ccb9b7 (diff)
downloadMasterServer-Perl-c3f8d65a4fb1f5674557ee67cf7f74369df86ad1.tar.gz
MasterServer-Perl-c3f8d65a4fb1f5674557ee67cf7f74369df86ad1.zip
Massive improvements on efficiency, robustness, security, reliability and more
Diffstat (limited to 'lib/MasterServer/Core/Stats.pm')
-rwxr-xr-xlib/MasterServer/Core/Stats.pm39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/MasterServer/Core/Stats.pm b/lib/MasterServer/Core/Stats.pm
new file mode 100755
index 0000000..25044e8
--- /dev/null
+++ b/lib/MasterServer/Core/Stats.pm
@@ -0,0 +1,39 @@
+
+package MasterServer::Core::Stats;
+
+use strict;
+use warnings;
+use AnyEvent::IO;
+use Exporter 'import';
+
+our @EXPORT = qw| update_stats |;
+
+################################################################################
+# Update statistics on servers and update the games table with those values
+################################################################################
+sub update_stats {
+ my $self = shift;
+
+ # get all gamenames where there is one or more servers online and update the
+ # stats per gamename.
+ my $games = $self->get_gamelist_stats();
+
+ # iterate through available stats
+ for my $e (@{$games}) {
+
+ # extract gamename, number of direct uplinks and total servers
+ my %opt = ();
+ $opt{gamename} = $e->[0];
+ $opt{num_uplink} = $e->[1];
+ $opt{num_total} = $e->[2];
+
+ # write to DB
+ $self->write_stat(%opt);
+ }
+
+ #done
+ $self->log("stat", "Updated all game statistics.");
+
+}
+
+1;