Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modqueue: link tags, optimize sql, use dtext in disapproval reasons. #2895

Merged
merged 3 commits into from Feb 28, 2017

Conversation

evazion
Copy link
Member

@evazion evazion commented Feb 25, 2017

This does several things:

  • formats detailed disapproval messages using dtext on the /posts/NNN page and in the modqueue.
  • in the modqueue, shows detailed disapproval messages for all disapproval types (disinterest/breaks rules/poor quality). Currently only distinterest messages are shown for some reason?
  • fixes a minor N+1 queries problem on the modqueue page. Reduces the total number of sql queries on that page from 47 to 13.
  • formats tag lists as colorized links, like in the /comments index.

Fixes an N+1 queries problem in the /moderator/post/queue view by
prefetching disapprovals and uploaders.

Also the way disapproval messages were previously rendered triggered a bunch
of sql queries for each post:

    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 [["post_id", 52]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND "post_disapprovals"."reason" = $2  [["post_id", 52], ["reason", "breaks_rules"]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND "post_disapprovals"."reason" = $2  [["post_id", 52], ["reason", "poor_quality"]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND "post_disapprovals"."reason" IN ('disinterest', 'legacy')  [["post_id", 52]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND (message is not null and message <> '')  [["post_id", 52]]
    SELECT "post_disapprovals".* FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND (message is not null and message <> '')  [["post_id", 52]]

This refactors to bring it down to one:

    SELECT "post_disapprovals".* FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1  [["post_id", 52]]
@r888888888 r888888888 merged commit 27a85cd into danbooru:master Feb 28, 2017
@evazion evazion deleted the fix-modqueue-dtext branch February 28, 2017 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants