]> git.sesse.net Git - pkanalytics/commitdiff
Make a table for the pulls category.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 10 May 2023 16:27:05 +0000 (18:27 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 10 May 2023 16:27:05 +0000 (18:27 +0200)
ultimate.js

index 7de103e86b385c6243508b307f1b4277182a95a1..798c582bea99043607bb0a89abbc7f8d2365a5dd 100644 (file)
@@ -193,22 +193,7 @@ function process_matches(json) {
        if (chosen_category === 'general') {
                rows = make_table_general(players);
        } else if (chosen_category === 'pulls') {
-               console.log("PULL STATS");
-               for (const [q,p] of Object.entries(players)) {
-                       if (p.pulls === 0) {
-                               continue;
-                       }
-                       let sum_time = 0;
-                       for (const t of p.pull_times) {
-                               sum_time += t;
-                       }
-                       let avg_time = 1e-3 * sum_time / p.pulls;
-                       let msg = p.name + ' did ' + p.pulls + ' pull(s), ' + p.oob_pulls + ' OOB';
-                       if (p.oob_pulls < p.pulls) {
-                               msg += ', avg. hangtime ' + avg_time.toFixed(1) + ' sec for others';
-                       }
-                       console.log(msg, p.pull_times);
-               }
+               rows = make_table_pulls(players);
        }
        document.getElementById('stats').replaceChildren(...rows);
 }
@@ -269,3 +254,38 @@ function make_table_general(players) {
        }
        return rows;
 }
+
+function make_table_pulls(players) {
+       let rows = [];
+       {
+               let header = document.createElement('tr');
+               add_cell(header, 'th', 'Player');
+               add_cell(header, 'th', 'Pulls');
+               add_cell(header, 'th', 'OOB pulls');
+               add_cell(header, 'th', 'Avg. hang time (IB)');
+               rows.push(header);
+       }
+       for (const [q,p] of Object.entries(players)) {
+               if (p.pulls === 0) {
+                       continue;
+               }
+               let sum_time = 0;
+               for (const t of p.pull_times) {
+                       sum_time += t;
+               }
+               let avg_time = 1e-3 * sum_time / p.pulls;
+               let oob_pct = 100 * p.oob_pulls / p.pulls;
+
+               let row = document.createElement('tr');
+               add_cell(row, 'td', p.name);  // TODO: number?
+               add_cell(row, 'td', p.pulls);
+               add_cell(row, 'td', p.oob_pulls + ' (' + oob_pct.toFixed(0) + '%)');
+               if (p.pulls > p.oob_pulls) {
+                       add_cell(row, 'td', avg_time.toFixed(1) + ' sec');
+               } else {
+                       add_cell(row, 'td', 'N/A');
+               }
+               rows.push(row);
+       }
+       return rows;
+}