First Accepted Answer badge not granted

badge

(Raphaël Jadot) #1

Continuing the discussion from Discourse Solved (Accepted answer plugin):

Hello :smiley:
I don’t know what I did wrong, but first Accepted Answer query doesn’t work for me…

I simply copy/pasted the query:

However no badge is granted for people who should theoretically get one…

Any hint, please?


(Kane York) #2

Anything show up if you use the “Preview” button?


(Alessio Fattorini) #3

Can you paste your query here?
When do you have created the badge? Do you know that you need to wait the daily cronjob?


(Raphaël Jadot) #4

Sorry for late answer, I was out for the week-end :smile:

@riking here is the preview result

No badges to be assigned. 

@alefattorini here is the copy paste:

 SELECT p.user_id, p.id post_id, p.updated_at granted_at
FROM badge_posts p
WHERE p.post_number > 1 AND 
    p.id IN (
      SELECT post_id FROM (
       SELECT pc.post_id, row_number() 
       OVER (PARTITION BY p1.user_id ORDER BY pc.created_at) as rnum
       FROM post_custom_fields pc
       JOIN badge_posts p1 ON p1.id = pc.post_id
       JOIN topics t1 ON p1.topic_id = t1.id
       WHERE name = 'is_accepted_answer' AND
                    p1.user_id <> t1.user_id AND 
        (
          :backfill OR 
           p1.user_id IN (
                   select user_id from posts where p1.id IN (:post_ids)
           )
       )
) X  WHERE rnum = 1)

I had created the badge two days before opening this post, and before some posts have been marked as solution:

Yes I guessed I had to wait until 24 hours max…