事件的数据浏览器查询?

我尝试查询一个简单的语句作为开始:

SELECT *
FROM discourse_post_event_invitees
WHERE post_id = :post_id

不幸的是,我收到 0 条结果,但我知道有一个帖子有 15 位用户标记为“参加”。有什么想法吗?

1 个赞

这应该可以。你从 JSON 中获取了正确的帖子 ID 吗?

我认为你可以将其链接到 posts 表并使用 topic ID,这可能比查找 post ID 更省事。类似这样:

-- [params]
-- topic_id :topic_id

SELECT ei.user_id, ei.status
FROM discourse_post_event_invitees ei
JOIN posts p ON p.id = ei.post_id
WHERE p.topic_id = :topic_id

2 个赞

好的,越来越接近了。这会返回所有“参加”或“感兴趣”的人,您如何区分?

好的,键“status”的名称让我有点困惑。我以为那是一种活动状态。

status = 0 = 将参加
status = 1 = 感兴趣
status = 2 = 不参加

2 个赞

如果不记得代码,也可以通过添加类似以下内容使其更易于阅读:


-- [params]
-- topic_id :topic_id

SELECT ei.user_id,
      CASE
       WHEN ei.status = 0 THEN 'Going'
       WHEN ei.status = 1 THEN 'Interested'
       WHEN ei.status = 2 THEN 'Not going'
        END AS "Going?"
FROM discourse_post_event_invitees ei
JOIN posts p ON p.id = ei.post_id
WHERE p.topic_id = :topic_id
ORDER BY ei.status

4 个赞