How could I find out how many users have each email setting?
I’m asking as only about a tenth of users watching a topic are being emailed post notifications.
Thank you.
How could I find out how many users have each email setting?
I’m asking as only about a tenth of users watching a topic are being emailed post notifications.
Thank you.
Die auf ihrer Seite Einstellungen/E-Mails? Dieses Feld befindet sich in der Tabelle user_options (email_level), und es gibt auch das für private Nachrichten (email_messages_level).
Ich glaube, das hier funktioniert. Es listet die Benutzer auf, die einem bestimmten Thema folgen, und zählt sie nach E-Mail-Level:
| Schlüssel | E-Mail-Level |
|---|---|
| 0 | Immer |
| 1 | Nur wenn abwesend |
| 2 | Nie |
-- [params]
-- int :topic_id
SELECT tu.topic_id AS topic_id,
uo.email_level,
COUNT(*)
FROM user_options uo
JOIN topic_users tu ON tu.user_id = uo.user_id
WHERE tu.notification_level = 3
AND tu.topic_id = :topic_id
GROUP BY topic_id, uo.email_level
Lass mich wissen, wenn ich etwas vermasselt habe. ![]()
![]()
Update:
Ich glaube, das hier funktioniert auch: (und wird etwas übersichtlicher angezeigt)
-- [params]
-- int :topic_id
SELECT tu.topic_id AS topic_id,
COUNT(CASE WHEN tu.notification_level = 3 THEN 1 END) AS watching,
COUNT(CASE WHEN uo.email_level = 0 THEN 1 END) AS always,
COUNT(CASE WHEN uo.email_level = 1 THEN 1 END) AS only_when_away,
COUNT(CASE WHEN uo.email_level = 2 THEN 1 END) AS never
FROM user_options uo
INNER JOIN topic_users tu ON tu.user_id = uo.user_id
WHERE tu.notification_level = 3
AND tu.topic_id = :topic_id
GROUP BY topic_id