og-statistics 1.0.0 → 2.0.1
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.
- package/package.json +1 -1
- package/src/index.js +10 -17
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -102,24 +102,17 @@ function filterStats(statsBase, keys = def, fallback = 0) {
|
|
|
102
102
|
card
|
|
103
103
|
*/
|
|
104
104
|
|
|
105
|
-
function filterIncidents(incidents) {
|
|
105
|
+
function filterIncidents(incidents, side = false) {
|
|
106
106
|
try {
|
|
107
|
-
//Cards, goals, substitutions
|
|
108
107
|
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const homeGoals = filterGoals(incidents.incidents, true);
|
|
113
|
-
const awayGoals = filterGoals(incidents.incidents, false);
|
|
114
|
-
|
|
115
|
-
const homeSubs = filterSubs(incidents.incidents, true);
|
|
116
|
-
const awaySubs = filterSubs(incidents.incidents, false);
|
|
108
|
+
const cards = filterCards(incidents.incidents, side);
|
|
109
|
+
const goals = filterGoals(incidents.incidents, side);
|
|
110
|
+
const subs = filterSubs(incidents.incidents, side);
|
|
117
111
|
|
|
118
112
|
return {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
cards,
|
|
114
|
+
goals,
|
|
115
|
+
subs
|
|
123
116
|
}
|
|
124
117
|
|
|
125
118
|
} catch (error) {
|
|
@@ -170,11 +163,11 @@ const filterGoals = (incidents, isHome) => {
|
|
|
170
163
|
};
|
|
171
164
|
|
|
172
165
|
function filterSubs(incidents, isHome) {
|
|
173
|
-
|
|
174
|
-
|
|
166
|
+
let teamIncidents = incidents.filter(s => s.isHome === isHome && s.incidentType === 'substitution');
|
|
167
|
+
let teamInjured = incidents.filter(s => s.isHome === isHome && s.incidentType === 'substitution' && s.injury === true);
|
|
175
168
|
|
|
176
169
|
return {
|
|
177
|
-
|
|
170
|
+
all: teamIncidents,
|
|
178
171
|
injured: teamInjured
|
|
179
172
|
}
|
|
180
173
|
}
|