Created
March 2, 2012 15:39
-
-
Save Pistos/1959222 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
posts.id | |
FROM "posts" | |
INNER JOIN "taggings" ON "posts"."id" = "taggings"."taggable_id" | |
AND "taggings"."taggable_type" = 'Post' | |
AND taggings.tagger_id IS NULL | |
AND taggings.context = 'tags' | |
INNER JOIN "tags" ON "tags"."id" = "taggings"."tag_id" | |
WHERE | |
"posts"."type" = 'StatusMessage' | |
AND "tags"."id" IN (2065, 55, 3987, 4, 15231, 6226, 56, 2486, 78) | |
AND (( public = 't' OR pod_only = 't' ) AND pending = 'f') | |
AND (posts.created_at < '2012-03-02 14:59:49.000000') | |
AND ( | |
COALESCE( | |
( | |
SELECT NOT sv.hidden | |
FROM share_visibilities sv | |
WHERE | |
sv.shareable_type = 'Post' | |
AND sv.shareable_id = posts.id | |
LIMIT 1 | |
), | |
TRUE | |
) | |
) | |
ORDER BY posts.created_at desc LIMIT 15; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
posts.id | |
FROM "posts" | |
INNER JOIN "taggings" ON "posts"."id" = "taggings"."taggable_id" | |
AND "taggings"."taggable_type" = 'Post' | |
AND taggings.tagger_id IS NULL | |
AND taggings.context = 'tags' | |
INNER JOIN "tags" ON "tags"."id" = "taggings"."tag_id" | |
WHERE | |
"posts"."type" = 'StatusMessage' | |
AND "tags"."id" IN (2065, 55, 3987, 4, 15231, 6226, 56, 2486, 78) | |
AND (( public = 't' OR pod_only = 't' ) AND pending = 'f') | |
AND (posts.created_at < '2012-03-02 14:59:49.000000') | |
AND NOT EXISTS ( | |
SELECT 1 | |
FROM share_visibilities sv | |
WHERE | |
sv.shareable_type = 'Post' | |
AND sv.shareable_id = posts.id | |
AND sv.hidden | |
LIMIT 1 | |
) | |
ORDER BY posts.created_at desc LIMIT 15; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT posts.id | |
FROM "posts" | |
WHERE "posts"."type" = 'StatusMessage' | |
AND (( public = 't' OR pod_only = 't' ) AND pending = 'f') | |
AND (posts.created_at < '2012-03-02 14:59:49.000000') | |
AND EXISTS | |
( | |
SELECT 1 FROM "taggings" | |
WHERE "taggings"."taggable_id" = "posts"."id" | |
AND "taggings"."taggable_type" = 'Post' | |
AND taggings.tagger_id IS NULL | |
AND taggings.context = 'tags' | |
AND "taggings"."tag_id" IN (2065, 55, 3987, 4, 15231, 6226, 56, 2486, 78) | |
) | |
AND NOT EXISTS ( | |
SELECT 1 | |
FROM share_visibilities sv | |
WHERE | |
sv.shareable_type = 'Post' | |
AND sv.shareable_id = posts.id | |
AND sv.hidden | |
) | |
ORDER BY posts.created_at desc | |
LIMIT 15 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment