Try to find recently signed player by name if necessary
Closed this issue · 0 comments
Currently a player item has to have a capfriendly id in order to be found when searching for recently signed players as retrieved from capfriendly.com. This leads to problem when the player already exists but has no capfriendly id assigned to yet. The current code then tries to create the player anew but encounters a psycopg2.IntegrityError because the corresponding player id already exists in the database.
A workaround would be to retrieve capfriendly ids before looking for recently signed players. This is usually a good practice, yet it shouldn't lead to an exception if not followed along.
Therefore the implementation should be changed to try and find a recently signed player by name as a second option after trying to find him via capfriendly id. For border cases (player not found due to name disparities) the code should additionally be hardened to not throw an exception.