# 如何重新计算所有 trust\_levels？

**URL:** https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602
**Category:** Support
**Created:** [2025 年6 月 18 日 01:12 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602 "2025-06-18T01:12:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [2025 年6 月 18 日 01:12 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602/1 "2025-06-18T01:12:15Z")

</div>

有一个 `rake jobs:recalculate_trust_level_for_all_users`，但它似乎不再起作用了。

有没有一种方法可以使用“更新”的参数重新计算所有信任等级？

我更改了所有信任等级的要求，但用户仍然保持在他们之前被授予的信任等级。

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2025 年6 月 25 日 18:32 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602/2 "2025-06-25T18:32:24Z")

</div>

这个方法怎么样？

> [@Modify trust level for all users](https://meta.discourse.org/t/modify-trust-level-for-all-users/103628):
>
> Here’s an example of a [bulk operation](https://meta.discourse.org/t/administrative-bulk-operations/118349) to set the trust level to 2 for all users currently at trust level 0 or 1: This is slow, but ensures that locked trust levels aren’t changed. But it may be preferred especially when you have fewer than 1000 users User.where(trust\_level: [0, 1]).find\_each do |user| user.change\_trust\_level!(TrustLevel[2]) end If there were more than 1000 users, I would have used this instead, but this would not respect locked trust levels. DB.exec("UPDATE users SET trus…

不。也许不是你想要的。🤔

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [2025 年6 月 25 日 18:47 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602/3 "2025-06-25T18:47:43Z")

</div>

谢谢你，Jammy，这并不是我想要的，但我最终做了类似的事情。  
问题通过变通方法解决了 🙂

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2025 年6 月 25 日 18:50 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602/4 "2025-06-25T18:50:35Z")

</div>

起初我有点当局者迷，但这正是我想要的：

> [@Discourse](#):
>
> ## 确保所有用户都处于其自动信任级别
> 
> * * *
> 
> 假设您将新用户或受邀用户的默认信任级别设置为一个不符合您预期（例如 TL4）的值。现在您想更改它，以便用户处于根据 [理解 Discourse 信任级别](https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/) 自动获得的信任级别。以下命令将确保所有用户都处于他们应有的信任级别。 **注意** ：锁定信任级别的用户不会受到影响。
> 
> 确保所有用户都设置为正确的信任级别：
> 
> ```plaintext
> rails c
> User.all.find_each do |user|
> Promotion.recalculate(user)
> end
> 
> ```
> 
> 刷新组统计信息以反映更改：
> 
> ```plaintext
> Group.ensure_consistency!
> 
> ```

---

<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: [2025 年7 月 25 日 18:51 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602/5 "2025-07-25T18:51:29Z")

</div>

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