og-statistics 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +22 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "og-statistics",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -455,4 +455,25 @@ function goalSummary(incidentsData, windowMinutes = 15) {
455
455
  }
456
456
  }
457
457
 
458
- module.exports = { filterStats, filterIncidents, goalSummary };
458
+ function pointAverage(jugadores) {
459
+
460
+ if (!Array.isArray(jugadores) || jugadores.length === 0) {
461
+ return '--';
462
+ }
463
+
464
+ let suma = 0;
465
+ let conteo = 0;
466
+
467
+ for (const j of jugadores) {
468
+ const s = j?.statistics;
469
+
470
+ if (s?.minutesPlayed > 0 && Number.isFinite(s.rating)) {
471
+ suma += s.rating;
472
+ conteo++;
473
+ }
474
+ }
475
+
476
+ return conteo ? Math.round((suma / conteo) * 100) / 100 : 0;
477
+ }
478
+
479
+ module.exports = { filterStats, filterIncidents, goalSummary, pointAverage };