# 只读模式是否会阻止用户获得奉献者徽章？

**URL:** https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746
**Category:** Support
**Tags:** read-only
**Created:** [2021年七月21日 10:27 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746 "2021-07-21T10:27:49Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2021年七月21日 10:27 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/1 "2021-07-21T10:27:50Z")

</div>

你好！

为了维护目的，我不得不将论坛设置为只读模式超过一天。

这会影响 [Devotee](https://meta.discourse.org/badges/47/devotee) 徽章的天数计数吗？

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [2021年七月21日 11:27 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/2 "2021-07-21T11:27:48Z")

</div>

嗨！  
🤔 我认为不会，只要用户仍然访问只读论坛，我就没找到任何理由说明会出问题。`"start"` 似乎仅与用户相关。

> <https://github.com/discourse/discourse/blob/1472e47aae5bfdfb6fd9abfe89beb186c751f514/lib/badge_queries.rb#L253-L273>

我记得用户标签页中的“最后访问”列在只读模式下依然有效，所以我的猜测是：你没问题 😅

---

<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年八月20日 11:27 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/3 "2021-08-20T11:27:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2022年一月1日 20:22 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/4 "2022-01-01T20:22:46Z")

</div>



---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022年一月1日 21:11 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/5 "2022-01-01T21:11:18Z")

</div>

“年度回顾”中提到，我的一些用户（包括我自己）今年只访问了 364 天，但我很确定这是错误的……

有没有什么快速的方法可以查看这些用户错过了哪一天？

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2022年一月3日 17:36 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/6 "2022-01-03T17:36:45Z")

</div>

为了回答您的第一个问题，我预计将网站设为只读模式会影响用户获得“Devotee”徽章的能力。当网站处于只读模式时，不会有新数据写入数据库，因此在网站处于只读模式时，用户访问的详细信息将不会被记录。

> [@Canapin](#):
>
> 有没有快速的方法可以看到这些用户错过了哪一天？

可以试试这个查询。它会返回用户在给定开始日期和结束日期之间未访问网站的日期：

### 用户未访问天数

```sql
--[params]
-- date :start_date
-- date :end_date
-- string :username

WITH days AS (
SELECT date_trunc('day', day)::date AS day
FROM generate_series(:start_date::date, :end_date::date, '1 day') AS day
),
users_visits AS (
SELECT
visited_at
FROM user_visits uv
JOIN users u ON u.id = uv.user_id
WHERE u.username = :username
AND visited_at BETWEEN :start_date AND :end_date
),
visits_days AS (
SELECT
day,
visited_at
FROM days
LEFT JOIN users_visits uv
ON uv.visited_at = day
ORDER BY day DESC
)

SELECT day AS days_without_visits
FROM visits_days WHERE visited_at IS NULL
ORDER BY day DESC

```

如果您想为一些不符合技术资格的用户授予徽章，请查看 [https://meta.discourse.org/t/how-to-award-a-non-custom-badge-through-the-console/103269。请注意，这种方法仅在自托管网站上可用。对于托管在我们服务器上的网站，我们可以为您授予该主题中列出的徽章。](https://meta.discourse.org/t/how-to-award-a-non-custom-badge-through-the-console/103269%E3%80%82%E8%AF%B7%E6%B3%A8%E6%84%8F%EF%BC%8C%E8%BF%99%E7%A7%8D%E6%96%B9%E6%B3%95%E4%BB%85%E5%9C%A8%E8%87%AA%E6%89%98%E7%AE%A1%E7%BD%91%E7%AB%99%E4%B8%8A%E5%8F%AF%E7%94%A8%E3%80%82%E5%AF%B9%E4%BA%8E%E6%89%98%E7%AE%A1%E5%9C%A8%E6%88%91%E4%BB%AC%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84%E7%BD%91%E7%AB%99%EF%BC%8C%E6%88%91%E4%BB%AC%E5%8F%AF%E4%BB%A5%E4%B8%BA%E6%82%A8%E6%8E%88%E4%BA%88%E8%AF%A5%E4%B8%BB%E9%A2%98%E4%B8%AD%E5%88%97%E5%87%BA%E7%9A%84%E5%BE%BD%E7%AB%A0%E3%80%82)

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022年一月3日 18:43 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/8 "2022-01-03T18:43:27Z")

</div>

非常感谢您详尽的回复。

查询确实显示用户在论坛只读的那天没有访问论坛。

我将从控制台授予徽章，感谢您提供这些额外信息 🙂

* * *

由于“Devotee”徽章不能授予多次，因此无法授予该徽章。但无论如何，知道这一点还是好的！

---

<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: [2022年二月2日 18:43 UTC](https://meta.discourse.org/t/does-read-only-mode-prevent-users-from-getting-the-devotee-badge/197746/9 "2022-02-02T18:43:58Z")

</div>

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