radar/forem — Issue #150: Not all topics showing
Author: jgadbois
Created: 2012-02-20 14:12:11+00:00
State: open

This may be an issue with Kaminari, but not all posts are showing for my topics. Here's some sample SQL:

```
irb(main):028:0> f.topics.visible.by_pinned_or_most_recent_post.page(1)

Forem::Topic Load (3.6ms) SELECT DISTINCT "forem_topics".id, forem_topics.pinned AS alias_0, forem_posts.created_at
AS alias_1, forem_topics.id AS alias_2 FROM "forem_topics" LEFT OUTER JOIN "forem_posts" ON "forem_posts"."topic_id" = "forem_topics"."id"
WHERE "forem_topics"."forum_id" = 1 AND "forem_topics"."hidden" = 'f' ORDER BY forem_topics.pinned DESC, forem_posts.created_at
DESC, forem_topics.id LIMIT 25 OFFSET 0

SQL (3.8ms) SELECT "forem_topics"."id" AS t0_r0, "forem_topics"."forum_id" AS t0_r1, "forem_topics"."user_id" AS t0_r2,
"forem_topics"."subject" AS t0_r3, "forem_topics"."created_at" AS t0_r4, "forem_topics"."updated_at" AS t0_r5, "forem_topics"."locked"
AS t0_r6, "forem_topics"."pinned" AS t0_r7, "forem_topics"."hidden" AS t0_r8, "forem_posts"."id" AS t1_r0, "forem_posts"."topic_id"
AS t1_r1, "forem_posts"."text" AS t1_r2, "forem_posts"."user_id" AS t1_r3, "forem_posts"."created_at" AS t1_r4, "forem_posts"."updated_at"
AS t1_r5, "forem_posts"."reply_to_id" AS t1_r6 FROM "forem_topics" LEFT OUTER JOIN "forem_posts" ON "forem_posts"."topic_id" =
"forem_topics"."id" WHERE "forem_topics"."forum_id" = 1 AND "forem_topics"."hidden" = 'f' AND "forem_topics"."id" IN (1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 186, 186, 186, 186, 186, 186, 186, 186, 190, 190, 186, 186, 180, 180) ORDER BY forem_topics.pinned DESC,
forem_posts.created_at DESC, forem_topics.id
```

It seems as if the IN clause isn't using topic IDs for some reason.