feat: CRM page listing trial prospects by MRR potential - #6589
Conversation
The daily scoring worker has been filling the `trial_prospects` table with no way to read it. This surfaces it in customer support so the CS team can prioritise outreach by estimated revenue potential, sortable by MRR and trial start date. Ranking and pagination live in Plausible.CustomerSupport.TrialProspects alongside the scoring rules they depend on — the over-top-tier-first order only makes sense next to the rule that leaves those rows with a null MRR.
|
|
||
| # Over-the-top-tier (Custom/Enterprise) prospects rank first | ||
| defp order_prospects(q, "mrr", direction) do | ||
| order_by(q, [p], [{^direction, p.over_top_tier}, {^direction, p.estimated_mrr}]) |
There was a problem hiding this comment.
| order_by(q, [p], [{^direction, p.over_top_tier}, {^direction, p.estimated_mrr}]) | |
| order_by(q, [p], [{^direction, p.estimated_mrr}]) |
Because PG ranks null value higher than integer, this simpler order by should give us the enterprise candidates top or bottom depending on sort direction.
There was a problem hiding this comment.
If we actually want them on top always, we need order_by(q, [p], [{:desc, p.over_top_tier}, {^direction, p.estimated_mrr}]) according to my testing.
| <div class="flex items-center justify-between"> | ||
| <h2 class="text-xl font-bold sm:text-2xl">🔥 Trial prospects</h2> | ||
| <p class="text-sm text-gray-500 dark:text-gray-400"> | ||
| {@total_entries} active trials — ranked by estimated MRR potential |
There was a problem hiding this comment.
| {@total_entries} active trials — ranked by estimated MRR potential | |
| {@total_entries} prospects |
I suggest to clarify this, because the query also covers recently expired trials.
I removed ranking string because it may be misleading when table is sorted by something else.
Alternatively, maybe something like
{@total_entries} prospects — ranked by {Phoenix.Naming.humanize(@sort_by)} {Phoenix.Naming.humanize(@sort_direction)}?
Surfaces the
trial_prospectstable in CRM.Changes
Please describe the changes made in the pull request here.
Below you'll find a checklist. For each item on the list, check one option and delete the other.
Tests
Changelog
Documentation
Dark mode