Badge query planner interpreting printf-style format specifiers?


(PJH) #1

Upon clicking Preview with query plan on the badge edit screen with the following in the query

...
        SELECT user_id, id, topic_id, post_number
        FROM posts
        WHERE raw LIKE '%c0a906d0-be88-11e4-bb52-0800200c9a66%' AND
        user_id IN  (....

I got:


(PJH) #2

%s:

%u:

%f:


(Sam Saffron) #3

@riking can you have a look at this?


(Sam Saffron) #4

Also, @PJH, the sock puppet account liking posts you want to ignore is tremendously more efficient, you don’t need to scan all raw text in all posts. Strongly recommend you change it.


(Jens Maier) #5

Did you try doubling all percent signs, i.e. LIKE '%%c0a...?


(Kane York) #6

While that could solve the problem, he shouldn’t need to do that!


(PJH) #7

… has nothing to do with this query.


(Sam Saffron) #8

What problem is this query solving?


(Kane York) #9

You can award badges to posts now by pasting in a link to the post in the /admin/user/_/badges screen, so you don’t actually need sql for those anymore.


(PJH) #10
  1. The < 0.5 seconds it takes to do the query on raw once per day per badge is - strangely - not less efficient than the 30+ seconds it takes to navigate to the admin/badge page and wait for it to render every time the badge needs to get awarded. Or to log into a sock-puppet to do whatever is needed.

  2. We don’t have the facility to link a badge to a post yet.


(Sam Saffron) #11

I fixed 1

New beta is slotted for tomorrow


(Sam Saffron) #12

Fixed per

https://github.com/discourse/discourse/commit/1e4c7dfbe77b853cd342687fb050183efd8b712b


(Sam Saffron) #13