Last active
July 11, 2019 18:48
-
-
Save Noxville/6c3694a0a175e8425a770277c3f85ddd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class LeagueMatchup { | |
League l | |
Team a | |
Team b | |
Date lastGameEnd | |
List<Team> getTeams() { | |
return [a,b] | |
} | |
boolean withinTime(Date d) { | |
return (d.time - lastGameEnd.time) < (1000L * 60 * 60 * 180) | |
} | |
String getKey() { | |
l.league_id + '|' + [a,b].collect { it.valve_id }.sort{}.join('|') // we want to ignore the start from the lookup | |
} | |
} | |
Map<Team, LeagueMatchup> prevLookup = [:] | |
Map<String, Series> seriesLookup = [:] | |
Matches.list().each { m -> | |
prevA = prevLookup.get(m.teams[0]) | |
prevB = prevLookup.get(m.teams[1]) | |
if ((prevA) && (prevB) && (prevA == prevB) && (prevA.withinTime(m.startDate)) { | |
Series series = seriesLookup.get(prevA.key) ?: new Series() | |
seriesLookup[prevA.key] = series | |
m.series = series | |
} | |
newLm = new LeagueMatchup(l: m.league, a: m.teams[0], b: m.teams[1], lastGame: m.startDate + m.duration) | |
m.teams.each { prevLookup[it] = newLm } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment