Multiple repeated summary mail entries

Here’s another one that just went out to an idle test user account:

  • last seen 2024-09-12
  • Digest frequency: daily
  • “Include content from new users in summary emails”: checked
  • no relevant tags muted

Popular Topics:

“A.I. - is bigger better?” – repeated 3 times. Topic has 3 tags, 0 replies, 0 likes.
“Social Engineering Challenges” – repeated 2 times. Topic has 2 tags, 1 replies, 0 likes.

New for You:

“New tag requests” – not repeated. Topic has 0 tags, 0 replies, 0 likes.

1 Like

In the latest digest one of my accounts received, none of the topics were duplicated, but the comments below them were (“Popular Posts”). There were five slots and two duplicates (three unique posts), both from the same topic.

Edit: I’m looking through some historical digests that were sent to different test/admin accounts:

  • The previous one also has two duplicates in the Popular Posts, also from that same topic.
  • The one before that had a duplicate topic but no duplicate Popular Posts. There’s a duplicate in “New for you”.
  • The one before that doesn’t have any duplicates.
1 Like

@j127, it would be interesting to know how many tags your digest topics had. In my recent samples, duplication corresponds with the number of tags on a topic. Might be a coincidence – or might not.

3 Likes

I’ve been able to reproduce the issue on my local Discourse site by adding a tag to the digest suppress tags site setting and then creating a topic with multiple tags.

The following code causes of the issue: discourse/app/models/topic.rb at main · discourse/discourse · GitHub

    if SiteSetting.digest_suppress_tags.present?
      tag_ids = Tag.where_name(SiteSetting.digest_suppress_tags.split("|")).pluck(:id)
      if tag_ids.present?
        topics =
          topics.joins("LEFT JOIN topic_tags tg ON topics.id = tg.topic_id").where(
            "tg.tag_id NOT IN (?) OR tg.tag_id IS NULL",
            tag_ids,
          )
      end
    end

Edit: I don’t think a LEFT JOIN is needed here. The columns from the joined topic_tags table don’t seem to get used later in the method. The fix could be as simple as:

if SiteSetting.digest_suppress_tags.present?
tag_ids = Tag.where_name(SiteSetting.digest_suppress_tags.split("|")).pluck(:id)
  if tag_ids.present?
  topics =
    topics.where.not(id: TopicTag.where(tag_id: tag_ids).select(:topic_id))
  end
end

I’ll leave it for the Discourse team to figure out the best approach. The for_digest method gets run a lot of times and needs to be efficient.

4 Likes

Yes, all the double posts had two tags.

2 Likes

@simon – thank you so much for running this down! :smiley: I’m sure it was a lot to sift through. I’ll look forward to the Discourse team returning & acting on your analysis.

1 Like

Just confirming that removing the tag I had in digest suppress tags has returned the summaries to normal. (I’m relying on digest suppress categories in the meantime.)

4 Likes

@simon was correct :+1: That was indeed the bug

7 Likes

Great news! :smiley:

I’m not entirely clear on when merged commits are available in the beta channel. If I’m on 3.4.0.beta3-dev (53f9c81790) and it’s not requesting a GUI update, will a command line update pick up this change?

You can still pull in the UI without it prompting for one, and it’ll pull the new commits in. But also doing a CLI rebuild would pull them in too.

1 Like

This topic was automatically closed after 3 days. New replies are no longer allowed.