/posted empty with a phpbb3 import

I did a phpbb3 import for a site. The admin user has thousands of posts, and that’s listed on the user summary page, and in https://estude.profcaju.com/u/USER/activity but when that user visits /posted they get only topics since the import.

When I look at I look at an imported topic that was created by the user, and pull up Topicuser for that topic/user, posted is set to false. I’ve run all of the ensure_consistency things I can find (TopicUser, Topic, User).

If I set posted to true in a TopicUser, it will show up in /posted.

Should I do something like TopicUser.where(user_id: 1).update_all(posted: true)? Should I do that for all users?


Thank you for reporting this Jay!

Seems like an issue with the ensure_consistency rake task. I just checked on a migration I’m working on now (haven’t run the ensure_consistency task yet) and the TopicUser records were already created with posted: false (the default). When the rake task reaches this point it generates a “duplicate key” error and the records are not created because of the ON CONFLICT DO NOTHING

def insert_topic_users
  log "Inserting topic users..."

  DB.exec <<-SQL
    INSERT INTO topic_users (user_id, topic_id, posted, last_read_post_number, first_visited_at, last_visited_at, total_msecs_viewed)
         SELECT user_id, topic_id, 't' , MAX(post_number), MIN(created_at), MAX(created_at), COUNT(id) * #{MS_SPEND_CREATING_POST}
           FROM posts
          WHERE user_id > 0
       GROUP BY user_id, topic_id

The TopicUser records are created at the create_topic step, more specifically here discourse/topic_creator.rb at main · discourse/discourse · GitHub.

I opened a PR with a fix that you could run now: