Closed hjone72 closed 8 years ago
I think cached_leagues needs to be declared in a higher scope to be reusable further down the script. I don't think it is actually declared at the point you try and use it as a cache.
Secondly, if we immediately find a perfect match we make the same GetLeagueDetails() call. Shall we also save that into the cache to be used later?
That is a way better idea than what I've done! I was only thinking about caching the results while making each call to search
.
Nice. You shouldn't be setting cached_leagues[i]['idLeague'] though right? Just cached_leagues['idLeague']?
Where is set cached_leagues[i]['idLeague']
set?
You're correct we should be using idLeague
as the key for the dict.
Sorry I wrote it wrong. Line 136 should use the league id not i as the key
Here are a few changes I made to the way leagues are matched.
I wasn't sure why each league was loaded on the first attempt, I've changed this to attempt to match the sport against the already loaded 'potential leagues' which already has the 'standard name'. If there is a match get the league details. If the above fails then call each league and try to match against the alternate names.
I made use of a
dict
when loading each leagues details from TSDB so that if that step failed, we wouldn't need to load them all again from TSDB.I also changed the
continue
tobreak
. I couldn't see a reason to continue to search through the 'potential' leagues?