Created
August 5, 2018 21:37
-
-
Save pjagielski/159e7d543fe0cc9db05895ccae3b4dd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn own-goal? [event] | |
(= "goal-own" (:type_of_event event))) | |
(defn own-goals [events] | |
(->> events (filter own-goal?))) | |
(defn remove-own-goals [events] | |
(remove own-goal? events)) | |
(defn fix-match [match-to-fix] | |
(let [own-home-goals (own-goals (:home_team_events match-to-fix)) | |
own-away-goals (own-goals (:away_team_events match-to-fix))] | |
(-> match-to-fix | |
(update :home_team_events remove-own-goals) | |
(update :away_team_events remove-own-goals) | |
(update :home_team_events concat own-away-goals) | |
(update :away_team_events concat own-home-goals)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment