# 自动化脚本Schedule PM使用Data Explorer结果未发送PMs

**URL:** https://meta.discourse.org/t/automation-script-schedule-pm-with-data-explorer-results-not-sending-pms/269135
**Category:** Bug
**Tags:** automation
**Created:** [2023年六月21日 09:46 UTC](https://meta.discourse.org/t/automation-script-schedule-pm-with-data-explorer-results-not-sending-pms/269135 "2023-06-21T09:46:11Z")
**Posts on this page:** 1
**Showing post:** 16

<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: [2023年六月21日 14:56 UTC](https://meta.discourse.org/t/automation-script-schedule-pm-with-data-explorer-results-not-sending-pms/269135/16 "2023-06-21T14:56:56Z")

</div>

我认为这与数据浏览器在将裸 ID 转换为可用链接时所做的 `user_id` 样式魔术有关。如果我按原样运行您的报告，它会像您看到的那样出错，但如果我从 SELECT 中删除 `t.user_id` 和 `t.last_post_user_id`，它确实有效。

如果我将它们转换为纯用户名，通过自动化似乎也能正常工作：

```sql

WITH
ua AS (
  SELECT target_topic_id, COUNT(id) FROM user_actions
  WHERE action_type = 15
  GROUP BY target_topic_id
)
SELECT
  t.id,
  t.title,
  t.created_at,
  t.last_posted_at,
  t.views,
  t.posts_count,
  us.username,
  u2.username
FROM topics t
INNER JOIN users us ON us.id = t.user_id
LEFT JOIN ua ON ua.target_topic_id = t.id
JOIN users u2 ON u2.id = t.last_post_user_id
WHERE t.deleted_at IS NULL
  AND t.closed = false
  AND t.archived = false
  AND t.visible = true
  AND ua.target_topic_id IS NULL
  AND us.username_lower != 'system'
  AND t.created_at > now() - INTERVAL '7' DAY
ORDER BY created_at DESC

```

不过，我们也已联系更专业的人员进行更详细的查看。👍 🙂

* * *

不过另外，我不确定您的查询是否能达到您想要的效果。这与解决方案有关吗？因为我在结果中看到了很多 PM。

---

_[View the full topic](https://meta.discourse.org/t/automation-script-schedule-pm-with-data-explorer-results-not-sending-pms/269135)._
