# 重建用户操作

**URL:** https://meta.discourse.org/t/rebuild-user-actions/174891
**Category:** Support
**Created:** [2021年一月3日 18:53 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891 "2021-01-03T18:53:23Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Ghan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ghan/32/177964_2.png) [@Ghan](https://meta.discourse.org/u/Ghan)
#### Post date: [2021年一月3日 18:53 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/1 "2021-01-03T18:53:23Z")

</div>

有没有办法重建用户操作？我使用批量导入工具完成了导入，该工具通过将点赞导入到 post\_actions 表中来处理点赞，但用户个人资料中的“活动-\>点赞”部分仍显示没有点赞。我认为点赞还需要在 user\_actions 表中有相应的条目。导入后，该表中仅包含 NEW\_TOPIC 和 REPLY 操作。

是否有 rake 任务可以重建用户操作，从而包含相关的帖子操作？还是说这需要在导入时直接处理？

---

<div class="post-metadata">

### Author: ![TheDarkWizard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thedarkwizard/32/177913_2.png) [@TheDarkWizard](https://meta.discourse.org/u/TheDarkWizard)
#### Post date: [2021年一月4日 05:50 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/2 "2021-01-04T05:50:35Z")

</div>

@sam

我注意到你在这里移除了重建用户操作的 rake 命令：[NoMethodError When Rebuilding User Actions - #3 by sam](https://meta.discourse.org/t/nomethoderror-when-rebuilding-user-actions/149507/3?u=thedarkwizard)

不过，在同一主题中，你当时建议人们参考正常的导入器以获取指导。你认为我们对于批量导入器应该怎么做？

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2021年一月4日 05:51 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/3 "2021-01-04T05:51:59Z")

</div>

> [@TheDarkWizard](#):
>
> 你认为我们该如何处理批量导入器？

老实说，我也不确定，也许 @zogstrip 知道。我猜你什么都不用做。

那个 rake 任务存在严重问题，因此已被移除。

---

<div class="post-metadata">

### Author: ![TheDarkWizard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thedarkwizard/32/177913_2.png) [@TheDarkWizard](https://meta.discourse.org/u/TheDarkWizard)
#### Post date: [2021年一月4日 06:01 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/4 "2021-01-04T06:01:00Z")

</div>

这是我们最重要的恢复导入测试。顺便说一句，批量导入简直太神奇了。

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/8/c8aa5d286c55f51a7fd0bf8e9bb2af03d7da5626.jpeg)

点赞已正确显示在所有地方，包括个人资料统计、帖子、私信等，但用户动态和“关于”统计页面中未显示。目前显示的那两条点赞，是我事后手动添加的。

我会等待 @zogstrip 如有可能给出反馈。希望能让点赞功能完全正常运行。

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [2021年一月4日 06:19 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/5 "2021-01-04T06:19:15Z")

</div>

> [@Ghan](#):
>
> 是否有现成的 rake 任务可以重建用户操作，使其包含相关的帖子操作？还是说这需要在导入时直接处理？

我不清楚是否有现成的 rake 任务，但几个月前我们将 vB3 迁移到 Discourse 时，编写了自定义代码，用于导入我们旧版 vB“感谢”插件中的所有点赞数据。

我们为此编写的一些自定义代码记录在此：

> [@Completed Migration vB3 to Discourse including Legacy vB3 Thank You to Likes](https://meta.discourse.org/t/completed-migration-vb3-to-discourse-including-legacy-vb3-thank-you-to-likes/144674):
>
> Just completed, for the most part (still in test bed, but the “hard parts” are basically done and the migration works fine), migrating a 15 year old vb3 forum, which was originally (believe-it-or-not) a vb2 forum from 2000. This forum has been around for around 20 years (with unimaginable custom PHP code, tables, plugins, etc), and Discourse is the only forum software, in my view, “worthy” of a migration project, which I started around a week ago, going from feasibility to completion (basically…

如果当时我就知道现在所知道的一切，我那时就会编写一个自定义的 rake 任务……

---

<div class="post-metadata">

### Author: ![Ghan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ghan/32/177964_2.png) [@Ghan](https://meta.discourse.org/u/Ghan)
#### Post date: [2021年一月4日 13:10 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/6 "2021-01-04T13:10:25Z")

</div>

这正是我的疑虑。两张表在导入过程中都需要填充数据。感谢提供参考资料！

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [2021年一月4日 13:27 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/7 "2021-01-04T13:27:42Z")

</div>

> [@Ghan，帖子：6，主题：174891](#):
>
> 感谢提供参考！

很乐意帮助一位同为网络移民的兄弟 🙂

很高兴我的“点赞致谢”迁移历程对您有帮助！

新年快乐

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2021年一月4日 16:15 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/8 "2021-01-04T16:15:17Z")

</div>

> [@Ghan](#):
>
> 有没有办法重建用户操作记录？

批量导入后，你运行了 [`import:ensure_consistency`](https://github.com/discourse/discourse/blob/6a9ec7c65d9017790f8e8028fb5d05ffc74d5f67/lib/tasks/import.rake#L5) rake 任务吗？

---

<div class="post-metadata">

### Author: ![Ghan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ghan/32/177964_2.png) [@Ghan](https://meta.discourse.org/u/Ghan)
#### Post date: [2021年一月4日 16:21 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/9 "2021-01-04T16:21:39Z")

</div>

> [@zogstrip](#):
>
> 批量导入后，你运行了 [`import:ensure_consistency`](https://github.com/discourse/discourse/blob/6a9ec7c65d9017790f8e8028fb5d05ffc74d5f67/lib/tasks/import.rake#L5) rake 任务吗？

是的。在那之后加上一些常规的 Sidekiq 任务，帖子操作似乎已被正确统计，但用户操作方面却未如此。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2021年二月3日 16:21 UTC](https://meta.discourse.org/t/rebuild-user-actions/174891/10 "2021-02-03T16:21:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
