# 如何查找用户查看主题的时长/谁发布了新主题/用户的国家

**URL:** https://meta.discourse.org/t/how-to-find-how-long-a-user-has-viewed-a-topic-who-has-posted-new-topics-country-of-users/287604
**Category:** Data & reporting
**Created:** [2023 年12 月 5 日 16:55 UTC](https://meta.discourse.org/t/how-to-find-how-long-a-user-has-viewed-a-topic-who-has-posted-new-topics-country-of-users/287604 "2023-12-05T16:55:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Maayan\_Mizrahi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maayan_mizrahi/32/332852_2.png) [@Maayan\_Mizrahi](https://meta.discourse.org/u/Maayan_Mizrahi)
#### Post date: [2023 年12 月 5 日 16:55 UTC](https://meta.discourse.org/t/how-to-find-how-long-a-user-has-viewed-a-topic-who-has-posted-new-topics-country-of-users/287604/1 "2023-12-05T16:55:35Z")

</div>

您好，

我想知道：

1. 用户在特定主题页面上停留多长时间？我能从 `post_timings` 表中获取信息吗？还是应该从其他来源获取？
2. 我在哪里可以找到发布新主题的用户数据？-  
 ![image](https://global.discourse-cdn.com/meta/original/4X/5/a/4/5a45c3320f47872f9dafa5a86eb26362ac68c1a1.png)
3. 我在哪里可以获取用户的国家信息？

提前感谢！

---

<div class="post-metadata">

### Author: ![jericson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jericson/32/116215_2.png) [@jericson](https://meta.discourse.org/u/jericson)
#### Post date: [2023 年12 月 5 日 21:30 UTC](https://meta.discourse.org/t/how-to-find-how-long-a-user-has-viewed-a-topic-who-has-posted-new-topics-country-of-users/287604/2 "2023-12-05T21:30:58Z")

</div>

我假设您已安装 [Data Explorer](https://meta.discourse.org/t/discourse-data-explorer/32566)。

> [@Maayan\_Mizrahi](#):
>
> 用户在特定主题页面停留多久？我能从 post\_timings 表中获取信息吗？还是应该从其他来源获取？

看起来您可以从 `post_timings` 中获取：

```plaintext
select topic_id,
       count(user_id) users,
       round(sum(msecs/(60*1000.0)),2)/count(user_id) avg_minutes
from post_timings
group by topic_id
order by avg(msecs) desc

```

我应该指出，这只包括已注册的用户。您可能需要使用 Google Analytics 来获取所有读者。

> [@Maayan\_Mizrahi](#):
>
> 在哪里可以找到发布新主题的用户的数据？

我不确定您在寻找什么数据。以下是如何查找每个用户的第一个帖子：

```plaintext
select p.id post_id
from posts p
where p.id = (select min(id) from posts where user_id = p.user_id)

```

如果想查找通过发布新主题而不是回复现有主题开始的用户，请添加 `and post_number = 1`。不确定其中任何一个是否有帮助。

> [@Maayan\_Mizrahi](#):
>
> 在哪里可以获取用户的国家信息？

人们可以填写他们的位置信息，这甚至可能被识别为国家：

```plaintext
select user_id, location
from user_profiles

```

根据我的经验，人们通常不 bother。所以 Google Analytics 可能更有用。

`users` 表中还有 `ip_address`，可用于查找位置数据。

---

<div class="post-metadata">

### Author: ![Maayan\_Mizrahi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maayan_mizrahi/32/332852_2.png) [@Maayan\_Mizrahi](https://meta.discourse.org/u/Maayan_Mizrahi)
#### Post date: [2023 年12 月 6 日 11:16 UTC](https://meta.discourse.org/t/how-to-find-how-long-a-user-has-viewed-a-topic-who-has-posted-new-topics-country-of-users/287604/3 "2023-12-06T11:16:16Z")

</div>

谢谢 @jericson！这很有帮助。
