]> git.sesse.net Git - pkanalytics/commitdiff
Fix counting of players that stayed on for a point but then had no events.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 10 May 2023 19:12:10 +0000 (21:12 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 10 May 2023 19:16:50 +0000 (21:16 +0200)
ultimate.js

index 4ccb9d59e5d4a401fed2341bb693e6c877356009..3b72f019737a0ff3b3f1e79152e371cd3269e40a 100644 (file)
@@ -86,15 +86,6 @@ function process_matches(json) {
                        let type = e['type'];
                        let p = players[e['player']];
 
-                       // Point count management
-                       if (p !== undefined && type !== 'out' && p.last_point_seen !== point_num) {
-                               p.last_point_seen = point_num;
-                               ++p.points_played;
-                       }
-                       if (type === 'goal' || type === 'their_goal') {
-                               ++point_num;
-                       }
-
                        // Sub management
                        if (type === 'in' && p.on_field_since === null) {
                                p.on_field_since = t;
@@ -108,12 +99,27 @@ function process_matches(json) {
                        } else if (type === 'goal' || type === 'their_goal' || type === 'stoppage') {
                                for (const [q,p] of Object.entries(players)) {
                                        if (p.on_field_since !== null) {
+                                               if (p.last_point_seen !== point_num) {
+                                                       // In case the player did nothing this point,
+                                                       // not even subbing in.
+                                                       p.last_point_seen = point_num;
+                                                       ++p.points_played;
+                                               }
                                                attribute_player_time(p, t, live_since);
                                        }
                                }
                                live_since = null;
                        }
 
+                       // Point count management
+                       if (p !== undefined && type !== 'out' && p.last_point_seen !== point_num) {
+                               p.last_point_seen = point_num;
+                               ++p.points_played;
+                       }
+                       if (type === 'goal' || type === 'their_goal') {
+                               ++point_num;
+                       }
+
                        // Pull management
                        if (type === 'pull') {
                                puller = e['player'];