Badges not being assigned

You have a query that is targetting posts there no? If not, you need to be selecting distinct user ids, looks like you are selecting dupes.