If a user does not submit the digest settings form on her profile, she'll get no digest emails.
On a site with 2 users, with only the second user explicitly subscribed and having an entry in {digests}, if the preliminary query in _digests_cron() is SELECT d.*, u.* /* We need the digests table first here, otherwise users with no digests row have uid = NULL in the results */ FROM users u LEFT JOIN digests d ON u.uid = d.uid WHERE status = 1 ; then we get 2 user results. However, if we take the whole conditional,
SELECT d.*, u.* /* We need the digests table first here, otherwise users with no digests row have uid = NULL in the results */ FROM users u LEFT JOIN digests d ON u.uid = d.uid WHERE status = 1 AND ( /* user is not blocked */ send_interval IS NULL OR /* user has not set their interval */ send_interval = 86400 /* user's interval is daily */ /* user's interval is weekly, and it's Sunday */ ) AND 1314123699 > COALESCE(last_sent, created) + (COALESCE(send_interval, 86400) - 43200) /* it's been at least (interval - 12 hours) since the last digest email */ AND ( 1314123699 /* NOW */ > 1314075600 /* SEND */ + timezone OR /* it's after send_time today */ 1314123699 /* NOW */ < 1314075600 /* SEND */ + timezone - 43200 /* it's more than 12hrs before send_time today, i.e. less than 12hrs since send_time yesterday */ OR timezone IS NULL /* the user has not set a timezone, fall back to the site default */ ) LIMIT 0, 250
Then we only get 1 result, and it's the user who has an entry in {digests}:
Sidenote, the query comments, while helpful, make the actual query harder to read. Could be better to have them not appear inline in the query.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 1257754.patch | 8.71 KB | ezra-g |
| #4 | 1257754-user-digests-b.patch | 2.41 KB | ezra-g |
| #3 | 1257754-user-digests.patch | 2.42 KB | ezra-g |
Comments
Comment #1
ezra-g commentedAdding commons release tag.
Comment #2
icecreamyou commentedI don't know how you're retrieving that query, but it's executed with appropriate line breaks and whitespace so that the comments should actually be helpful.
Query looks right to me. All the columns in the digests table have OR IS NULL or COALESCE() checks so that they're not required. Not sure what would cause the problem you're experiencing. I would break that conditional apart and try running each part of it manually to see which part causes only 1 user to be returned.
Comment #3
ezra-g commentedHere's an attempt at resolving this.
I discussed a bit in IRC with greggles, and he provided helpful feedback as well.
Comment #4
ezra-g commentedHere's a revision with a slightly more sane send interval ;).
Comment #5
ezra-g commentedHere's an in-progress patch for discussion on IRC.
Comment #6
icecreamyou commentedI can't reproduce this issue, but I think I've figured out #1256732: Daily email summaries are not being sent at the correct time of day.
Comment #7
ezra-g commentedWe had trouble reproducing this as a team.