Ref T12270. Moves badges into their own page and menu item. Capable of displaying hundreds of useful tokens of appreciation and dedication.
pat pat pat
This was pre-existing, but this is pretty expensive ("Load every badge the user can view and edit") and won't scale particularly well -- maybe just always show the button? I'd guess users can mostly figure it out.
There's no way to make "does any object exist which the user has X permission" on efficient in the general case. If an install has like 5,000 badges that query is going to take like 30 seconds to run no matter what.
You could do "limit 1" to make it less bad but the way "limit 1" works right now will actually make it way way worse.