fix: Return all obtained levels for badges#79
Conversation
|
Partially fixes #78
|
|
I couldn't test the fix because I immediately found another serious error that made it impossible to check. My bf2 account has all medals and badges. When I spawn on the map I immediately get the Combat Infantry Medal and in loop, every second I always get the same medal until the end of the round. Here my round bf2 server logs My bf2 Playername: TEST my medal_data.py (default, I didn't make any changes) |
|
Thanks guys, I've finally had time to look at this. Haven't used ASP v3 much myself, so I'm not very familiar with the code, and especially the SQL schema enough to give advice if there may be a more optimized query. The explanation and code does seem to make sense though. If this fix does resolve the error, perhaps we could merge this first. 😃 |

I was wondering why I kept getting basic badges (level
1) in game even though I already had the corresponding badge with a higher level. Turns out the current implementation only returns the highest awarded level for badges due to theGROUP BY award_id + COUNT. The game server is thus told that I don't have the lower level badges yet, leading it to award the level1badge again.The endpoint needs to always return all awarded levels of a badge. The query exploded in size a bit, but I didn't really see any alternatives. Medals require the
GROUP BYto merge the individual rows into one containing theCOUNT. But badges must not be grouped and ribbons don't really care (single row anyway). Hence theUNIONof two different queries. I also moved settingfirstto zero from the write loop to the query and sorted the query results by award id and level to make the response easier to read.Note: Performance does not seem to be impacted by the change.