-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Für meine Anzeige muss ich wissen, für welches Team dieses Tor gefallen ist. Unabhängig davon ob es ein Elfmeter, Eigentor oder was auch immer ist.
Zur Zeit setze ich die property goalFor selbst. Ich denke, dass das eine wichtige Information ist und es wäre cool, wenn wir das in die Source einbauen könnten.
Hier ist meine Implementierung in Javascript (bzw. beschränktem Typescript)
Ich modifiziere die Daten zwar ein bisschen, aber das Ergebnis ist erkennbar.
const modifyGoal = (goal: OldbGoal): WgdGoal => ({
oldb_id: goal.goalID,
home : goal.scoreTeam1,
away : goal.scoreTeam2,
minute : goal.matchMinute,
scorer : {
name : goal.goalGetterName,
oldb_id: goal.goalGetterID,
},
penalty : goal.isPenalty,
ownGoal : goal.isOwnGoal,
overtime: goal.isOvertime,
});
const addGoalFor = ({ goals }: OldbData) => goals.reduce( (acc, cur) => {
const model = modifyGoal(cur);
if (!acc.length) {
model.goalFor = model.home > model.away ? 'home' : 'away';
} else {
model.goalFor = acc[acc.length - 1].home === model.home ? 'away' : 'home';
}
acc.push(model);
return acc;
}, [] as `WgdGoal[]);`Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels