Question Answer Plugin

Moving this discussion over here from #support

I’m running 2.7.0.beta1 and when I installed the Q&A plugin replies to posts started to appear in random order. Others started to exhibit the same issues identified in this thread.

@AJDurant came up with this query (below) to fix the order issue, but it did not solve the problem. The plugin still seems to post replies to posts in the wrong order. I uninstalled the plugin and ran:

rake posts:reorder_posts[1896]

but it did not reorder the previous posts.

I’m afraid to run this query without further investigation by someone qualified to evaluate the fix. Any thoughts on how to fix this?

 SELECT
    id,
    ROW_NUMBER() OVER (
      PARTITION BY
        topic_id
      ORDER BY
        created_at,
        post_number
    ) AS new_post_number
  FROM
    posts
  /*where*/
)
UPDATE
  posts AS p
SET
  sort_order = o.new_post_number
FROM
  ordered_posts AS o
WHERE
  p.id = o.id AND
  p.sort_order <> o.new_post_number