Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(warehouse-suggestions): simplify the suggested models review (#123348)

Thiago Salvatore674bfd458500
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 95ec5a1770fc..60803494a71c 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -16933,13 +16933,13 @@ snapshots:
warehouse-suggestions-suggested-certifications--deprecate-dialog--light:
hash: v1.k794b7964.275d7a88a60faa93a269cf2845b2699cbfdf64e3e44915475a0b2bee1cd74d5f.NhxpoIwZXgvWwn3rUmWDa0TNkY2A7ZVGRJmHW1vAuBM
warehouse-suggestions-suggested-certifications--review-dialog--dark:
- hash: v1.k794b7964.f40a28243e534bd2e853fbe4b5a26023cb9504457623d3b6af862164adc8beec.Vk2go7D3Eeokdeci-ETbg4CwjMaGcIVCUnq2CALbooM
+ hash: v1.k794b7964.c2b43a0d616ad1721b228b10987d7037c535206a67312f0f5232e1d654f5a60f.rdxQcav4UGFzP3u8nSdaulyhqN-7BhEZ0Rs9mfwcwBA
warehouse-suggestions-suggested-certifications--review-dialog--light:
- hash: v1.k794b7964.c69b36fc213c5041b9cf4fc4c7bee3fc2410edeffa6c4e2828dac7e9033d875b.oOCy4rL-e1tGSlOlQrxRyD6XoZJRa0B6j4qGehpNj9Y
+ hash: v1.k794b7964.74c4fc0a2c87a70eb1977ff6bd0f70194222e0fa010c54bf0ea75b5080456701.9OjN8DSZcWSlxnK5UIhIIX4ZVQDVtP8e-mOT4Ou8EkA
warehouse-suggestions-suggested-certifications--review-dialog-narrow--dark:
- hash: v1.k794b7964.ce522445bf9083771c46bc68d8f3b9ebeb4863384dc0d74ca7c37de2cb97217e.Fhb4YxSBLnQNXOdEp51XQUBJVUQ_74Hr-DADW5lnN8s
+ hash: v1.k794b7964.2344ac79fcee901cfbc8892f79a4631821485c3e289e2b89d47676033d4b4bcc.PaeOI1dpFwA7RrGpai9PDerfXQ2nesADnpDH5LvFz4o
warehouse-suggestions-suggested-certifications--review-dialog-narrow--light:
- hash: v1.k794b7964.9263e2efe8a89c1e9994047ab40108008e80a9b5768200ac32d847fd02589278.Iz0T5upcUumqKb7Eu9mwn9Gql0NCkb-LyEHntUd2rXo
+ hash: v1.k794b7964.f77388a8153d3551ce0de3d75b0346268f50c8ac70bc8b10e333b083a9f40cf3.x67YoR-C0-RrxNWsOM1Mv7QOmlMEJD4S2CmZBkwbLyk
warehouse-suggestions-suggested-models-strip--banner--dark:
hash: v1.k794b7964.95ba4716f680e32e7497d3f5d8dbcdca2f9da83d7e08e5b2bb8911a7ab2c39fb.ackP53GYozYXF74XgG1MVnH6degCJR3pkvrXGKJJ3hw
warehouse-suggestions-suggested-models-strip--banner--light:
@@ -16953,33 +16953,33 @@ snapshots:
warehouse-suggestions-suggested-models-strip--load-failed--light:
hash: v1.k794b7964.a5b60b08e7b0a541c14bae9a0a40118fced381d13bfdd40b8e93342959f24f19.LwTgelFpFnRFgNgu3ueAFF9dCIqGgJGMgoyv53ZJe9g
warehouse-suggestions-suggested-models-strip--materialize-dialog-incremental-proposal--dark:
- hash: v1.k794b7964.74f9d19ad93bb618504d2d403e1725ce7fbe501bf78a121822d8f20ad690203e.bPzGeVdTDg_mPVKZsK_HJ0leK8dC-nlU2Ay61tXAbe4
+ hash: v1.k794b7964.032b237f6b064b97c2967bd3371fc5976b56d2bc53bc7c1477ccb179d4328bba.VLngPFGD7X4zR-A3lBUzSXTlEFyxiyJSRJrSW9nASVQ
warehouse-suggestions-suggested-models-strip--materialize-dialog-incremental-proposal--light:
- hash: v1.k794b7964.efe5a247e0cf30df05eb016b063f27bc0c6e7004a7c5346d37cd7001870e150a.n04UaOgI7AGNJC7wRti796r6i9Z4fZ488jp3EdumyaY
+ hash: v1.k794b7964.615fefa2b72edb8e3ac52f8a40b643d70e2266cf4087ec2e530ea416a663737c.a3kwJ5OMMvvy16QIvO_03BUCME2Ludg6KRs9zLcMsjw
warehouse-suggestions-suggested-models-strip--materialize-dialog-longer-schedule-unknown-sources--dark:
- hash: v1.k794b7964.855f3ea2845ba5dd3c810636cf5045fe81e6a9d28ae0db6ce2a01fdeb4a11221.Dv3G7SN4YTJgzY4l_Wu1y3XuM3gwcGvK0tV5WMDq0nU
+ hash: v1.k794b7964.837f31cbe827ec69c755f8423ec7d5e42176a1805d981b43752c770785121525.2iRbK4dl5sZVs6YlAWvlp5yksawu-ePXJEJkqefBOBI
warehouse-suggestions-suggested-models-strip--materialize-dialog-longer-schedule-unknown-sources--light:
- hash: v1.k794b7964.0f6806dc8fbf944d32de7a93a9923d99e49eb8799d1f4fc0d23a6e6ce3cdf6f2.3Mhy6e_YfeA5cqAuT-IoGajBOBBd7Xdsn9wj1ZWWP5w
+ hash: v1.k794b7964.14635082a49901aafdf5cae1f184665676ca385cc9c3b4b5288279d158aa5151.k1NZ1ZVAxd9pGr0zl8OjMJcubGjeVcEanuNve-CnsiI
warehouse-suggestions-suggested-models-strip--not-eligible--dark:
hash: v1.k794b7964.b646d37c91e92fd3d0053e1407559117a50c06c45f8ff7f4bcaaed18bab1cfef.1vguAxzgXrCyuyN1v2jRBSTSGDrmsu62f3nO60GFvGc
warehouse-suggestions-suggested-models-strip--not-eligible--light:
hash: v1.k794b7964.a66ac5be916b459b6f8b15621e3bdeb12226d34c1e24feb15900940652fc238b.gzxwnKSQkZQfg5wdIMriKJO-aaxIteiXVzfSx1R7w8c
warehouse-suggestions-suggested-models-strip--review-dialog--dark:
- hash: v1.k794b7964.d7281956d6a6d9500df44c8505e89d4a3a2741e69315d6662cc393c385dcdfac.PIDsknoPIZcTNh5840COUHo2Lgpi2L114i_1g-8aWQc
+ hash: v1.k794b7964.6704636139e679bff06ae8ac293a11a79512d2ebb1b40ba860c5b92cf68914f9.kV00kEDOPcXei1uIUD98ZpiGTl7yWEKLc6gM-cB68QQ
warehouse-suggestions-suggested-models-strip--review-dialog--light:
- hash: v1.k794b7964.8d03834be6be77e9fa4da3bf3e86fdd5364c0300a636ff6320ebc1e36aba2ab6.ItiXQCCUfNoe1z2aeuaXltIeUu3AdNgCglj6O0vYP2c
+ hash: v1.k794b7964.ee48017846790bc155b3d56bf09deb212250a7b8c0cc109f80b17c2129ee9678.XXIsgSRudiZQJhR5z6up89pCNSrNxZ8cN4Idf6Lc9gk
warehouse-suggestions-suggested-models-strip--review-dialog-many-suggestions--dark:
- hash: v1.k794b7964.df444e3dda3ca63b178c15440c87b97e0acf9c562cc143f66071e84e7e8cadab.VHVGDerYpYEiTemqHE__doI0aiCHhtYA5jOKjig6Fes
+ hash: v1.k794b7964.1fe85a2835e1f5b317fc8c9158864742c8cc75923b0dbd46a511a60353f4c8c2.U8fMH_bEQlPHWoc33EeE3R8PIyeVhkymf-tNrBqrD3U
warehouse-suggestions-suggested-models-strip--review-dialog-many-suggestions--light:
- hash: v1.k794b7964.75542fd854ab00627b79b61eb91c531f9a66177aa596f43128f56e8bbfaa6305.r54lMWbzjAt6mU4Tb4wbtQtP0Pok3jNpn_ENQYgk7Zo
+ hash: v1.k794b7964.49dc6fecf31a0af324cd77fab6201ed3b56d9c0924eef3fe0152568efe000a67.naBylAMmZJ8rGTSgezEL-SsV-CDkWfPDTV16Cbo4ed0
warehouse-suggestions-suggested-models-strip--review-dialog-viewer-without-edit-access--dark:
- hash: v1.k794b7964.2c87edc2f08ccb22d0cf99f5da81ff8af9d9d671aeaf69660f141c55109899d8.GeV--pV6uq1BCKojjyd-ZyGtRvnQhUiZ_4nZzXPTWSw
+ hash: v1.k794b7964.fd6be2b86f1b8d3c97f42d616f18bd03cd847c1aab8b2b1705c28432eb9f82c4.YjRSp1tHz_wptuaPolsSoQ5UA2xJx9KTlx9Uts3f6R4
warehouse-suggestions-suggested-models-strip--review-dialog-viewer-without-edit-access--light:
- hash: v1.k794b7964.bdd1546b1dbf5ea2bd54daecd79393039cc829a9f45f3982f518a3cc62790e22._UaFRRY155i2kx7xUMV9D-f2RdkTiYzT5XR4LNAM0YA
+ hash: v1.k794b7964.e28785f4439ef22c26f953323b5e859d0822054f6b92396eb237c535b9f0a41e.Lj4zRNVtLh5Nolx2M5A8OSnyuUG_fv2ghcjzkd2mGjg
warehouse-suggestions-suggested-models-strip--stop-materializing-dialog--dark:
- hash: v1.k794b7964.c59a50b5effd37216385a041de8fc64779bf250c284ac4333bd448dad326ea2f.AyjUcsLu5aIG9b7DQ0SHo0IcVbYDju5e8TMT65_dSO0
+ hash: v1.k794b7964.f1bbacf85ccb9c90e8980f0fb2b76e9a88dc44ae6c0fc7b438ae175166fbc107.clj4aF0nN4fRaxCxUKGQ2D9Heh3ztyfzBq_yJYD3B6o
warehouse-suggestions-suggested-models-strip--stop-materializing-dialog--light:
- hash: v1.k794b7964.ff1705f7ffddfcce15d27b15b4c105b29f7743d2f3584edd7a5de2dd87066882.eNjSCnNSrBfujqxMYzk0yXuaUyVHDNRmL_VIvLpiJRM
+ hash: v1.k794b7964.24a5826c28aedc9559806790ce28842b7c878d79efd405ffdefe5e88540b1b76.sfIdeW-Q3n9Zny2O-_OVvnRewQjqNytyAkzYljzaEoU
warehouse-suggestions-suggested-models-strip--warming-up--dark:
hash: v1.k794b7964.860407091149fedd6c4e056cda79d92213e59dd9e00886e0cedee320fc267c48.x5QcsRUSRT66uOc237oq_n4D-eQWpY2GzsTRTC-SL6w
warehouse-suggestions-suggested-models-strip--warming-up--light:
diff --git a/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsx
index 7fed4d48539d..64a9824409bc 100644
--- a/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsx
+++ b/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsx
@@ -11,7 +11,7 @@ import { AccessControlLevel, AccessControlResourceType } from '~/types'
import type { WarehouseSuggestionApi } from '../generated/api.schemas'
import { daysReadLabel, isDeprecatePayload, noReadsLabel, readSummary, refreshCostLabel } from '../suggestionCopy'
import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'
-import { DismissSuggestionMenu } from './DismissSuggestionMenu'
+import { DismissSuggestionButtons } from './DismissSuggestionButtons'
import { SuggestionRow } from './SuggestionRow'
import { SuggestionSubjectLink } from './SuggestionSubjectLink'
import { WhyThisSuggestion } from './WhyThisSuggestion'
@@ -88,7 +88,7 @@ export function CertificationSuggestionRow({ suggestion, windowDays }: Certifica
>
{deprecating ? 'Mark deprecated' : 'Certify'}
</LemonButton>
- <DismissSuggestionMenu
+ <DismissSuggestionButtons
suggestionId={suggestion.id}
kind={suggestion.kind}
disabledReason={blockedReason ?? (inFlight ? 'Working' : undefined)}
diff --git a/products/warehouse_suggestions/frontend/components/DismissSuggestionButtons.tsx b/products/warehouse_suggestions/frontend/components/DismissSuggestionButtons.tsx
new file mode 100644
index 000000000000..f7b1fc128a4f
--- /dev/null
+++ b/products/warehouse_suggestions/frontend/components/DismissSuggestionButtons.tsx
@@ -0,0 +1,44 @@
+import { useActions } from 'kea'
+
+import { IconClock, IconX } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { notNowCondition } from '../suggestionCopy'
+import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'
+
+export interface DismissSuggestionButtonsProps {
+ suggestionId: string
+ kind: string
+ disabledReason?: string
+}
+
+export function DismissSuggestionButtons({
+ suggestionId,
+ kind,
+ disabledReason,
+}: DismissSuggestionButtonsProps): JSX.Element {
+ const { dismissSuggestion } = useActions(warehouseSuggestionsLogic)
+
+ return (
+ <>
+ <LemonButton
+ size="small"
+ type="tertiary"
+ icon={<IconClock />}
+ tooltip={`Not now. ${notNowCondition(kind)}`}
+ disabledReason={disabledReason}
+ onClick={() => dismissSuggestion(suggestionId, 'not_now')}
+ data-attr="warehouse-suggestions-not-now"
+ />
+ <LemonButton
+ size="small"
+ type="tertiary"
+ icon={<IconX />}
+ tooltip="Dismiss. Won't be suggested again."
+ disabledReason={disabledReason}
+ onClick={() => dismissSuggestion(suggestionId, 'not_useful')}
+ data-attr="warehouse-suggestions-dismiss"
+ />
+ </>
+ )
+}
diff --git a/products/warehouse_suggestions/frontend/components/DismissSuggestionMenu.tsx b/products/warehouse_suggestions/frontend/components/DismissSuggestionMenu.tsx
deleted file mode 100644
index 6570efbc3f8f..000000000000
--- a/products/warehouse_suggestions/frontend/components/DismissSuggestionMenu.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { useActions } from 'kea'
-
-import { LemonButton, LemonMenu } from '@posthog/lemon-ui'
-
-import { notNowCondition } from '../suggestionCopy'
-import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'
-
-export interface DismissSuggestionMenuProps {
- suggestionId: string
- kind: string
- disabledReason?: string
-}
-
-export function DismissSuggestionMenu({ suggestionId, kind, disabledReason }: DismissSuggestionMenuProps): JSX.Element {
- const { dismissSuggestion } = useActions(warehouseSuggestionsLogic)
-
- return (
- <LemonMenu
- items={[
- {
- label: "Not useful. Won't be suggested again.",
- onClick: () => dismissSuggestion(suggestionId, 'not_useful'),
- },
- {
- label: `Not now. ${notNowCondition(kind)}`,
- onClick: () => dismissSuggestion(suggestionId, 'not_now'),
- },
- { label: 'Something else', onClick: () => dismissSuggestion(suggestionId, 'other') },
- ]}
- >
- <LemonButton
- size="small"
- type="tertiary"
- disabledReason={disabledReason}
- data-attr="warehouse-suggestions-dismiss"
- >
- Dismiss
- </LemonButton>
- </LemonMenu>
- )
-}
diff --git a/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx
index 9c13bb55ea16..86531bfd184b 100644
--- a/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx
+++ b/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx
@@ -1,14 +1,14 @@
import { useActions, useValues } from 'kea'
+import { IconCheck } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
import type { WarehouseSuggestionApi } from '../generated/api.schemas'
-import { dataAgeLabel, isMaterializePayload, materializeSaving, readSummary, savingHighlight } from '../suggestionCopy'
+import { isMaterializePayload, materializeSaving, readSummary, savingHighlight } from '../suggestionCopy'
import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'
-import { DataAgeMeta } from './DataAgeMeta'
-import { DismissSuggestionMenu } from './DismissSuggestionMenu'
+import { DismissSuggestionButtons } from './DismissSuggestionButtons'
import { SuggestionRow } from './SuggestionRow'
import { SuggestionSubjectLink } from './SuggestionSubjectLink'
import { WhyThisSuggestion } from './WhyThisSuggestion'
@@ -50,10 +50,6 @@ export function MaterializeSuggestionRow({
windowDays={windowDays}
label={readSummary(suggestion.evidence)}
/>,
- <DataAgeMeta key="age" age={dataAgeLabel(payload, payload.refresh_interval_seconds)} />,
- ...(payload.refresh_mode === 'incremental'
- ? [<span key="mode">{`Incremental by ${payload.incremental_key ?? 'new rows'}`}</span>]
- : []),
]}
highlight={savingHighlight(materializeSaving(payload))}
actions={
@@ -61,13 +57,13 @@ export function MaterializeSuggestionRow({
<LemonButton
size="small"
type="secondary"
+ icon={<IconCheck />}
+ tooltip="Materialize"
disabledReason={blockedReason}
onClick={() => openMaterializeModal(suggestion.id)}
data-attr="warehouse-suggestions-materialize"
- >
- Materialize
- </LemonButton>
- <DismissSuggestionMenu
+ />
+ <DismissSuggestionButtons
suggestionId={suggestion.id}
kind={suggestion.kind}
disabledReason={blockedReason}
diff --git a/products/warehouse_suggestions/frontend/components/SuggestedModelsSection.tsx b/products/warehouse_suggestions/frontend/components/SuggestedModelsSection.tsx
new file mode 100644
index 000000000000..9c158f504b71
--- /dev/null
+++ b/products/warehouse_suggestions/frontend/components/SuggestedModelsSection.tsx
@@ -0,0 +1,28 @@
+import { ReactNode } from 'react'
+
+import { cn } from 'lib/utils/css-classes'
+
+import { SAVING_COLUMNS_CLASS } from './SuggestionRow'
+
+export interface SuggestedModelsSectionProps {
+ title: string
+ description: string
+ children: ReactNode
+}
+
+export function SuggestedModelsSection({ title, description, children }: SuggestedModelsSectionProps): JSX.Element {
+ return (
+ <section aria-label={title}>
+ <div className={cn('grid grid-cols-1 items-end px-3 pt-4 pb-1', SAVING_COLUMNS_CLASS)}>
+ <div className="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5">
+ <h4 className="m-0 text-sm font-semibold">{title}</h4>
+ <span className="text-xs text-secondary">{description}</span>
+ </div>
+ <span className="hidden text-right text-xs text-secondary @min-[36rem]/suggestions:block">
+ Saves a month
+ </span>
+ </div>
+ <div className="divide-y divide-primary">{children}</div>
+ </section>
+ )
+}
diff --git a/products/warehouse_suggestions/frontend/components/SuggestedModelsStripContent.tsx b/products/warehouse_suggestions/frontend/components/SuggestedModelsStripContent.tsx
index 9e1160c1bd6d..d87a999a9056 100644
--- a/products/warehouse_suggestions/frontend/components/SuggestedModelsStripContent.tsx
+++ b/products/warehouse_suggestions/frontend/components/SuggestedModelsStripContent.tsx
@@ -11,14 +11,26 @@ import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'
import { MaterializeSuggestionModal } from './MaterializeSuggestionModal'
import { MaterializeSuggestionRow } from './MaterializeSuggestionRow'
import { SavingsBannerMessage } from './SavingsBannerMessage'
+import { SuggestedModelsSection } from './SuggestedModelsSection'
import { SuggestionsBanner } from './SuggestionsBanner'
import { SuggestionsReviewModal } from './SuggestionsReviewModal'
import { SuggestionsStatusNotice } from './SuggestionsStatusNotice'
import { UnmaterializeSuggestionModal } from './UnmaterializeSuggestionModal'
import { UnmaterializeSuggestionRow } from './UnmaterializeSuggestionRow'
+const SECTION_COPY: Record<string, { title: string; description: string }> = {
+ materialize: {
+ title: 'Materialize',
+ description: 'These views run their full query every time someone reads them.',
+ },
+ unmaterialize: {
+ title: 'Stop materializing',
+ description: 'These views cost more to refresh than to run on each read.',
+ },
+}
+
export function SuggestedModelsStripContent(): JSX.Element | null {
- const { stripState, listedSuggestions, savingsSummary, status } = useValues(warehouseSuggestionsLogic)
+ const { stripState, suggestionGroups, savingsSummary, status } = useValues(warehouseSuggestionsLogic)
const { reload } = useActions(warehouseSuggestionsLogic)
const windowDays = status?.window_days ?? 0
@@ -76,17 +88,25 @@ export function SuggestedModelsStripContent(): JSX.Element | null {
title="Suggested models"
summary={<SavingsBannerMessage summary={savingsSummary} />}
>
- {listedSuggestions.map((suggestion) =>
- suggestion.kind === 'unmaterialize' ? (
- <UnmaterializeSuggestionRow
- key={suggestion.id}
- suggestion={suggestion}
- windowDays={windowDays}
- />
- ) : (
- <MaterializeSuggestionRow key={suggestion.id} suggestion={suggestion} windowDays={windowDays} />
- )
- )}
+ {suggestionGroups.map(({ kind, suggestions }) => (
+ <SuggestedModelsSection key={kind} {...SECTION_COPY[kind]}>
+ {suggestions.map((suggestion) =>
+ kind === 'unmaterialize' ? (
+ <UnmaterializeSuggestionRow
+ key={suggestion.id}
+ suggestion={suggestion}
+ windowDays={windowDays}
+ />
+ ) : (
+ <MaterializeSuggestionRow
+ key={suggestion.id}
+ suggestion={suggestion}
+ windowDays={windowDays}
+ />
+ )
+ )}
+ </SuggestedModelsSection>
+ ))}
</SuggestionsReviewModal>
<MaterializeSuggestionModal />
<UnmaterializeSuggestionModal />
diff --git a/products/warehouse_suggestions/frontend/components/SuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/SuggestionRow.tsx
index cf48f42192cd..c3c3005f655e 100644
--- a/products/warehouse_suggestions/frontend/components/SuggestionRow.tsx
+++ b/products/warehouse_suggestions/frontend/components/SuggestionRow.tsx
@@ -2,9 +2,11 @@ import { ReactNode } from 'react'
import { cn } from 'lib/utils/css-classes'
-import { COMBINED_SAVING_LABEL, SavingHighlight } from '../suggestionCopy'
+import { SavingHighlight } from '../suggestionCopy'
const AMOUNT_CLASS = 'text-sm font-semibold tabular-nums text-success'
+export const SAVING_COLUMNS_CLASS =
+ '@min-[36rem]/suggestions:grid-cols-[minmax(0,1fr)_10rem_7.5rem] @min-[36rem]/suggestions:gap-x-3'
export interface SuggestionRowProps {
suggestionId: string
@@ -37,9 +39,7 @@ export function SuggestionRow({
<div
className={cn(
'grid grid-cols-1 gap-y-2 px-3 py-2.5 @min-[36rem]/suggestions:items-center @min-[36rem]/suggestions:gap-x-3',
- highlight
- ? '@min-[36rem]/suggestions:grid-cols-[minmax(0,1fr)_10rem_minmax(15rem,auto)]'
- : '@min-[36rem]/suggestions:grid-cols-[minmax(0,1fr)_auto]'
+ highlight ? SAVING_COLUMNS_CLASS : '@min-[36rem]/suggestions:grid-cols-[minmax(0,1fr)_auto]'
)}
>
<div className="flex min-w-0 items-start gap-2">
@@ -53,19 +53,7 @@ export function SuggestionRow({
<span translate="no" className={AMOUNT_CLASS}>
{highlight.amount}
</span>
- {highlight.bytes && (
- <>
- <span aria-hidden className="text-muted">
- ·
- </span>
- <span translate="no" className={AMOUNT_CLASS}>
- {highlight.bytes.amount}
- </span>
- </>
- )}
- <span className="text-xs text-secondary">
- {highlight.bytes ? COMBINED_SAVING_LABEL : highlight.label}
- </span>
+ <span className="text-xs text-secondary">{highlight.narrowLabel}</span>
</div>
)}
<div className="flex flex-wrap items-baseline gap-x-4 gap-y-0.5 overflow-hidden text-xs text-secondary">
@@ -85,10 +73,9 @@ export function SuggestionRow({
<span translate="no" className={AMOUNT_CLASS}>
{highlight.amount}
</span>
- <span className="text-xs text-secondary">{highlight.label}</span>
- {highlight.bytes && (
+ {highlight.detail && (
<span translate="no" className="text-xs tabular-nums text-secondary">
- {`${highlight.bytes.amount} ${highlight.bytes.label}`}
+ {highlight.detail}
</span>
)}
</div>
diff --git a/products/warehouse_suggestions/frontend/components/SuggestionsReviewModal.tsx b/products/warehouse_suggestions/frontend/components/SuggestionsReviewModal.tsx
index 5c27343ab7fe..ba90480b501e 100644
--- a/products/warehouse_suggestions/frontend/components/SuggestionsReviewModal.tsx
+++ b/products/warehouse_suggestions/frontend/components/SuggestionsReviewModal.tsx
@@ -42,10 +42,10 @@ export function SuggestionsReviewModal({ title, summary, children }: Suggestions
footer={
<div className="flex w-full flex-wrap items-center justify-between gap-2">
<span className="min-w-0 flex-1 whitespace-normal text-xs text-muted">
- <span>Based on read counts from the query log. PostHog never reads your query text.</span>
+ <span>{`Based on the last ${status?.window_days ?? 0} days of reads. Cached dashboard views aren't counted.`}</span>
{status?.refreshed_at && (
<>
- <span> Refreshed </span>
+ <span> Updated </span>
<TZLabel time={status.refreshed_at} showPopover={false} />
<span>.</span>
</>
diff --git a/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx
index aeed86cc3297..6f8a68b0dd8c 100644
--- a/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx
+++ b/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx
@@ -1,19 +1,14 @@
import { useActions, useValues } from 'kea'
+import { IconCheck } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
import type { WarehouseSuggestionApi } from '../generated/api.schemas'
-import {
- isUnmaterializePayload,
- readSummary,
- readTimeLabel,
- savingHighlight,
- unmaterializeSaving,
-} from '../suggestionCopy'
+import { isUnmaterializePayload, readSummary, savingHighlight, unmaterializeSaving } from '../suggestionCopy'
import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'
-import { DismissSuggestionMenu } from './DismissSuggestionMenu'
+import { DismissSuggestionButtons } from './DismissSuggestionButtons'
import { SuggestionRow } from './SuggestionRow'
import { SuggestionSubjectLink } from './SuggestionSubjectLink'
import { WhyThisSuggestion } from './WhyThisSuggestion'
@@ -55,7 +50,6 @@ export function UnmaterializeSuggestionRow({
windowDays={windowDays}
label={readSummary(suggestion.evidence)}
/>,
- <span key="read-time">{readTimeLabel(payload.read_seconds)}</span>,
]}
highlight={savingHighlight(unmaterializeSaving(payload))}
actions={
@@ -63,13 +57,13 @@ export function UnmaterializeSuggestionRow({
<LemonButton
size="small"
type="secondary"
+ icon={<IconCheck />}
+ tooltip="Stop materializing"
disabledReason={blockedReason}
onClick={() => openAcceptConfirm(suggestion.id)}
data-attr="warehouse-suggestions-unmaterialize"
- >
- Stop materializing
- </LemonButton>
- <DismissSuggestionMenu
+ />
+ <DismissSuggestionButtons
suggestionId={suggestion.id}
kind={suggestion.kind}
disabledReason={blockedReason}
diff --git a/products/warehouse_suggestions/frontend/components/WhyThisSuggestion.tsx b/products/warehouse_suggestions/frontend/components/WhyThisSuggestion.tsx
index 4a068afa63db..ad977f3ebd7e 100644
--- a/products/warehouse_suggestions/frontend/components/WhyThisSuggestion.tsx
+++ b/products/warehouse_suggestions/frontend/components/WhyThisSuggestion.tsx
@@ -1,7 +1,7 @@
import { Tooltip } from '@posthog/lemon-ui'
import type { WarehouseSuggestionEvidenceApi } from '../generated/api.schemas'
-import { QUERY_LOG_CAVEAT, daysReadLabel, surfaceSegments } from '../suggestionCopy'
+import { daysReadLabel, surfaceSegments } from '../suggestionCopy'
import { ReadsBySurfaceBar } from './ReadsBySurfaceBar'
export interface WhyThisSuggestionProps {
@@ -14,13 +14,16 @@ export function WhyThisSuggestion({ evidence, windowDays, label }: WhyThisSugges
const segments = surfaceSegments(evidence)
const daysRead = (evidence.human_days ?? 0) > 0 ? daysReadLabel(evidence, windowDays) : null
+ if (segments.length === 0 && !daysRead) {
+ return <span translate="no">{label}</span>
+ }
+
return (
<Tooltip
title={
<div className="flex w-64 max-w-full flex-col gap-2 py-0.5">
{segments.length > 0 && <ReadsBySurfaceBar segments={segments} />}
{daysRead && <span>{daysRead}</span>}
- <span className="opacity-75">{QUERY_LOG_CAVEAT}</span>
</div>
}
>
@@ -31,11 +34,7 @@ export function WhyThisSuggestion({ evidence, windowDays, label }: WhyThisSugges
>
<span translate="no">{label}</span>
<span className="sr-only">
- {[
- segments.map((segment) => `${segment.label} ${segment.count}`).join(', '),
- daysRead,
- QUERY_LOG_CAVEAT,
- ]
+ {[segments.map((segment) => `${segment.label} ${segment.count}`).join(', '), daysRead]
.filter(Boolean)
.map((part) => `. ${part}`)
.join('')}
diff --git a/products/warehouse_suggestions/frontend/suggestionCopy.test.ts b/products/warehouse_suggestions/frontend/suggestionCopy.test.ts
index dbb54e42b733..1a3178da66a4 100644
--- a/products/warehouse_suggestions/frontend/suggestionCopy.test.ts
+++ b/products/warehouse_suggestions/frontend/suggestionCopy.test.ts
@@ -56,21 +56,21 @@ describe('suggestionCopy', () => {
{ seconds: 17 * 60, bytes: 3.2 * TB },
{
amount: '~17 minutes',
- label: 'query time saved a month',
- bytes: { amount: '~3.20 TB', label: 'less scanned' },
+ detail: '~3.20 TB less scanned',
+ narrowLabel: 'saved a month, ~3.20 TB less scanned',
},
'Saves about 17 minutes of query time and 3.20 TB of scanning a month',
],
[
'time and too few bytes to name',
{ seconds: 17 * 60, bytes: 40 * MB },
- { amount: '~17 minutes', label: 'query time saved a month' },
+ { amount: '~17 minutes', detail: null, narrowLabel: 'saved a month' },
'Saves about 17 minutes of query time a month',
],
[
'only bytes',
{ seconds: 30, bytes: 40 * MB },
- { amount: '~40.00 MB', label: 'less data scanned a month' },
+ { amount: '~40.00 MB', detail: 'less scanned', narrowLabel: 'less scanned a month' },
'Saves about 40.00 MB of scanning a month',
],
])('names every saving worth naming when a suggestion saves %s', (_name, saving, highlight, sentence) => {
diff --git a/products/warehouse_suggestions/frontend/suggestionCopy.ts b/products/warehouse_suggestions/frontend/suggestionCopy.ts
index 8294c48ecaaa..1e4b31c2be8f 100644
--- a/products/warehouse_suggestions/frontend/suggestionCopy.ts
+++ b/products/warehouse_suggestions/frontend/suggestionCopy.ts
@@ -31,16 +31,11 @@ const SURFACE_LABELS: Record<string, string> = {
unknown: 'Other',
}
export const UNKNOWN_SOURCES_CAVEAT = 'Some sources have no sync schedule, so their age is unknown.'
-export const QUERY_LOG_CAVEAT = 'Counts come from the query log. Cached dashboard views are not counted.'
-export const COMBINED_SAVING_LABEL = 'saved a month'
-export interface SavingAmount {
+export interface SavingHighlight {
amount: string
- label: string
-}
-
-export interface SavingHighlight extends SavingAmount {
- bytes?: SavingAmount
+ detail: string | null
+ narrowLabel: string
}
export interface SurfaceSegment {
@@ -157,12 +152,13 @@ export function refreshModeLabel(incremental: boolean, incrementalKey: string |
export function savingHighlight(saving: MonthlySaving): SavingHighlight {
const { time, bytes } = namedSaving(saving, 1)
if (!time) {
- return { amount: `~${bytes}`, label: 'less data scanned a month' }
+ return { amount: `~${bytes}`, detail: 'less scanned', narrowLabel: 'less scanned a month' }
}
+ const scanned = bytes ? `~${bytes} less scanned` : null
return {
amount: `~${time}`,
- label: 'query time saved a month',
- ...(bytes ? { bytes: { amount: `~${bytes}`, label: 'less scanned' } } : {}),
+ detail: scanned,
+ narrowLabel: scanned ? `saved a month, ${scanned}` : 'saved a month',
}
}
@@ -208,7 +204,7 @@ export function certificationSummaryText(suggestions: WarehouseSuggestionApi[]):
}
export function readSummary(evidence: WarehouseSuggestionEvidenceApi): string {
- return `${countOf(evidence.human_requests ?? 0, 'read', 'reads')} · ${countOf(evidence.human_users ?? 0, 'person', 'people')}`
+ return `${countOf(evidence.human_requests ?? 0, 'read', 'reads')} by ${countOf(evidence.human_users ?? 0, 'person', 'people')}`
}
export function daysReadLabel(evidence: WarehouseSuggestionEvidenceApi, windowDays: number): string {
diff --git a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.ts b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.ts
index 4d26735d54c9..cdcfa0ecb72c 100644
--- a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.ts
+++ b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.ts
@@ -492,10 +492,10 @@ describe('warehouseSuggestionsLogic', () => {
unmaterialize('unread-mid', 3000, 1500),
materialize('time-big', 2400),
],
- ['time-big', 'unread-mid', 'time-small', 'bytes-big'],
+ ['time-big', 'time-small', 'bytes-big', 'unread-mid'],
],
['catalog', [certification('old', 'deprecate'), certification('used', 'certify')], ['used', 'old']],
- ])('orders %s suggestions by what they are worth', async (surface, results, expectedOrder) => {
+ ])('orders %s suggestions by kind, then by what they are worth', async (surface, results, expectedOrder) => {
mockList.mockResolvedValue(page(results))
await mountLogic(surface)
diff --git a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.ts b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.ts
index 76d066e637f1..399c87d79173 100644
--- a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.ts
+++ b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.ts
@@ -56,6 +56,10 @@ import {
export type StripState = 'loading' | 'error' | 'hidden' | 'warming_up' | 'not_eligible' | 'active' | 'all_done'
export type SuggestionSurface = 'models' | 'catalog'
+export interface SuggestionGroup {
+ kind: string
+ suggestions: WarehouseSuggestionApi[]
+}
export interface WarehouseSuggestionsLogicProps {
surface: SuggestionSurface
@@ -114,6 +118,14 @@ function compareSuggestions(a: WarehouseSuggestionApi, b: WarehouseSuggestionApi
return groupA - groupB || valueA - valueB
}
+function groupedByKind(suggestions: WarehouseSuggestionApi[]): SuggestionGroup[] {
+ const kindsByBestSuggestion = [...new Set(suggestions.map((suggestion) => suggestion.kind))]
+ return kindsByBestSuggestion.map((kind) => ({
+ kind,
+ suggestions: suggestions.filter((suggestion) => suggestion.kind === kind),
+ }))
+}
+
function proposedRefreshDraft(payload: WarehouseSuggestionMaterializePayloadApi): IncrementalConfigDraft {
return {
enabled: payload.refresh_mode === 'incremental',
@@ -197,6 +209,7 @@ export interface warehouseSuggestionsLogicValues {
status: WarehouseSuggestionStatusApi | null
statusLoading: boolean
stripState: StripState
+ suggestionGroups: SuggestionGroup[]
suggestions: WarehouseSuggestionApi[] | null
suggestionsLoading: boolean
surfaceSuggestions: WarehouseSuggestionApi[]
@@ -361,6 +374,7 @@ export interface warehouseSuggestionsLogicMeta {
hiddenSuggestionIds: string[],
surface: SuggestionSurface
) => WarehouseSuggestionApi[]
+ suggestionGroups: (listedSuggestions: WarehouseSuggestionApi[]) => SuggestionGroup[]
surfaceSuggestions: (
listedSuggestions: WarehouseSuggestionApi[],
leavingSuggestionIds: string[]
@@ -570,15 +584,21 @@ export const warehouseSuggestionsLogic: LogicWrapper<warehouseSuggestionsLogicTy
suggestions: WarehouseSuggestionApi[] | null,
hiddenIds: string[],
surface: SuggestionSurface
- ): WarehouseSuggestionApi[] =>
- (suggestions ?? [])
+ ): WarehouseSuggestionApi[] => {
+ const byWorth = (suggestions ?? [])
.filter(
(suggestion) =>
suggestion.surfaced_at !== null &&
!hiddenIds.includes(suggestion.id) &&
SURFACE_KINDS[surface].includes(suggestion.kind)
)
- .sort(compareSuggestions),
+ .sort(compareSuggestions)
+ return groupedByKind(byWorth).flatMap((group) => group.suggestions)
+ },
+ ],
+ suggestionGroups: [
+ (s) => [s.listedSuggestions],
+ (listed: WarehouseSuggestionApi[]): SuggestionGroup[] => groupedByKind(listed),
],
surfaceSuggestions: [
(s) => [s.listedSuggestions, s.leavingSuggestionIds],