Skip to content

Conversation

@rpapani
Copy link
Contributor

@rpapani rpapani commented Jan 17, 2026

Problem
We send up to 10 URLs to Mystique for generating high-organic-low-ctr opportunities. While some pages get dropped (if headline/CTA can't be found), we may still end up with up to 10 opportunities, which can look spammy.

Solution

Limit the maximum number of high-organic-low-ctr opportunities to 3 per site using an eviction strategy based on pageViews:

  • When receiving a new opportunity and at capacity (3), compare page views
  • If new opportunity has higher page views → replace the lowest existing one
  • If new opportunity has lower page views → drop it and log a warning
  • Updating an existing opportunity (same URL) bypasses the capacity check

Known limitation
Since Mystique sends suggestions asynchronously and SQS may process multiple messages concurrently, there's a potential race condition where more than 3 opportunities could be created before the capacity check takes effect. However, this scenario has very low chances.

@rpapani rpapani requested review from FentPams and ramboz January 17, 2026 23:24
@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link

This PR will trigger a patch release when merged.

Copy link

@ramboz ramboz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me.

I'm not sure about the UX. My understanding from the code is that if we have an existing set of 3 opptys on Friday, and the practitioner sees them, then on Monday we could potentially have 3 new ones that replace them. It doesn't meant the initial 3 are fixed, just that they are not the most important ones anymore. Correct?

Feels a bit like we could end up with opptys popping up and disappearing every other week (or so) in an extreme case. Not sure if this is the desired UX :)

@rpapani
Copy link
Contributor Author

rpapani commented Jan 24, 2026

@ramboz

I'm not sure about the UX. My understanding from the code is that if we have an existing set of 3 opptys on Friday, and the practitioner sees them, then on Monday we could potentially have 3 new ones that replace them. It doesn't meant the initial 3 are fixed, just that they are not the most important ones anymore. Correct?

Yes, this is the current behavior, with out this change as well.

Feels a bit like we could end up with opptys popping up and disappearing every other week (or so) in an extreme case. Not sure if this is the desired UX :)

Yes, this is intended. We should always show the latest opportunities with latest data. If a page is no longer relevant, we should delete that and show what's important from the latest run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants