: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(warehouse-suggestions): link to details pages and show bytes saved (#122874)
Thiago Salvatore3fcbe4fff796
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex bbce06a465eb..4fe6b6160387 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -16885,25 +16885,25 @@ snapshots:warehouse-suggestions-suggested-certifications--banner--light:hash: v1.k794b7964.4398ae40c8e28494481e73b72c49315fd5294380aaa8f4f579c53b120e95d2f3.qj1-k55d9dyizhho1p59SKxeUPeAKHr6ZRnFAkcZgIAwarehouse-suggestions-suggested-certifications--deprecate-dialog--dark:- hash: v1.k794b7964.379398a0bc13a5f75b341a3ea524b9ba0a640cbb3a97b0a93e4a79a9dbb980e2.xhvNtFSq3a9qkI9V2wIMnvaBeXCY3h8eXO2De84KhOU+ hash: v1.k794b7964.09b0aec605e49d00a60ef65ad6a4e44157179bfcd307e22500d1f0c95dcca84b.ffeyTu9F9ltSOuDHuRiBk66vNteeBGXBOuZdMSNUEWQwarehouse-suggestions-suggested-certifications--deprecate-dialog--light:- hash: v1.k794b7964.966ef9d3e4d2e372c4540477ff29f30cf40cfa14fc00f8f20b3598daddb07bc2.Rtpa4Ja7OqI5c5VN5sETaXj1brjK8ejBUvxu1gsqMWQ+ hash: v1.k794b7964.275d7a88a60faa93a269cf2845b2699cbfdf64e3e44915475a0b2bee1cd74d5f.NhxpoIwZXgvWwn3rUmWDa0TNkY2A7ZVGRJmHW1vAuBMwarehouse-suggestions-suggested-certifications--review-dialog--dark:- hash: v1.k794b7964.89802b93fe9b475b2c41505c82c562a9c805a3022fa7b0f31d792ee4e26aa356.12Jokr27QXDdzls30bzHiJBVcmY-YW7jGvpMdjl5qvs+ hash: v1.k794b7964.f40a28243e534bd2e853fbe4b5a26023cb9504457623d3b6af862164adc8beec.Vk2go7D3Eeokdeci-ETbg4CwjMaGcIVCUnq2CALbooMwarehouse-suggestions-suggested-certifications--review-dialog--light:- hash: v1.k794b7964.0f6fb7eb4f579c64837df55cbd4f4df7ed124b75d5d394379c2ac621e65112b1.vEB6Jtzs9i2qSzZpJ1I-oMPSP2YZvLsNeFptGLvDnIw+ hash: v1.k794b7964.c69b36fc213c5041b9cf4fc4c7bee3fc2410edeffa6c4e2828dac7e9033d875b.oOCy4rL-e1tGSlOlQrxRyD6XoZJRa0B6j4qGehpNj9Ywarehouse-suggestions-suggested-certifications--review-dialog-narrow--dark:- hash: v1.k794b7964.5f9dc23fe422a76659ed69cdf41b77dfe2270f03d6e0fd86565ba931cb552d95.OJ6su46_HVfPGBbzt_9f_PN91F0Y-4UVu_yGV8xZrFE+ hash: v1.k794b7964.ce522445bf9083771c46bc68d8f3b9ebeb4863384dc0d74ca7c37de2cb97217e.Fhb4YxSBLnQNXOdEp51XQUBJVUQ_74Hr-DADW5lnN8swarehouse-suggestions-suggested-certifications--review-dialog-narrow--light:- hash: v1.k794b7964.3b5047b043fe10ce37b2e876db33158911951f7f181f76826df4703d0cf4d9c0.ZMOGZUA32lzC4cpnm9eWc99cU9xXecUWujMH99JdztY+ hash: v1.k794b7964.9263e2efe8a89c1e9994047ab40108008e80a9b5768200ac32d847fd02589278.Iz0T5upcUumqKb7Eu9mwn9Gql0NCkb-LyEHntUd2rXowarehouse-suggestions-suggested-models-strip--banner--dark:- hash: v1.k794b7964.5eab43c7f6811e5ca0651c1dbe3fbe44dd21387f05d24d07de36a6603a24cf8d.ouJOT_N_8rEwDbxsI92aGh8Seefi1ctVoAgMybcFsV0+ hash: v1.k794b7964.95ba4716f680e32e7497d3f5d8dbcdca2f9da83d7e08e5b2bb8911a7ab2c39fb.ackP53GYozYXF74XgG1MVnH6degCJR3pkvrXGKJJ3hwwarehouse-suggestions-suggested-models-strip--banner--light:- hash: v1.k794b7964.33924e399de75936e19314e3aa0eb7dc1697570862cc893bae3b4cd062e0b360.tZ8DSfGDLOGG7Xc_kXI7uC_CyU5l7vOPkwNKxNu9o6I+ hash: v1.k794b7964.e5c0612cb28d10889c2e12d45e301179b8486fd9c4955bc7c263a0bbeb3e48d1.HaP6FZCwy8IjEBBE3PN0v965whOBqLoHFu2ydHAP42wwarehouse-suggestions-suggested-models-strip--banner-narrow--dark:- hash: v1.k794b7964.696f466f94d41f530c407436ba73a3eb523005e63e056605b3d457546d0ee045.isZjSiaKcjcu-ztNvw7lQeDodFOk4683ViotSunRT5w+ hash: v1.k794b7964.a9f0234e6bbdb3fddad0a01f6412e0e04b441b242b584398f294310f11f7fb90.t0yZHTlHGZRUmTmMvB222jaOopi7-Qp33bjpXHvVbr0warehouse-suggestions-suggested-models-strip--banner-narrow--light:- hash: v1.k794b7964.f779330a9ab26a6d5ef120c66ae00f45d956d306abcf213688582cdadf375d61.LVyCJ00Z48VEVXdT1oQwMC6y_NGbdqhXAMxK_-yG448+ hash: v1.k794b7964.4853cd549edce121e6b9f987c5bf96dfac76926581745f457f5421afdf0d0bf1.0z4Cvnvp5G-qwQBMck2dkiQSMmEOF3JMwp5dDT5Dk38warehouse-suggestions-suggested-models-strip--load-failed--dark:hash: v1.k794b7964.d93ab3575b7bebf7f869bc5b41c0a8e0581679f22bd0251c31f031b0f43ee7c0.iXXukenkQJA0ayAlRoqei_RQx1XW-b9MLaTjdhxfkoMwarehouse-suggestions-suggested-models-strip--load-failed--light:@@ -16913,29 +16913,29 @@ snapshots:warehouse-suggestions-suggested-models-strip--materialize-dialog-incremental-proposal--light:hash: v1.k794b7964.efe5a247e0cf30df05eb016b063f27bc0c6e7004a7c5346d37cd7001870e150a.n04UaOgI7AGNJC7wRti796r6i9Z4fZ488jp3EdumyaYwarehouse-suggestions-suggested-models-strip--materialize-dialog-longer-schedule-unknown-sources--dark:- hash: v1.k794b7964.caeb876c239ab68a4910791a582803479d5c395fd32439a2bed416e1ecce46ad.W9QtU1TJIvsJukrw_k6_ZyQMeNxaGfuUYR6wuop5bOQ+ hash: v1.k794b7964.855f3ea2845ba5dd3c810636cf5045fe81e6a9d28ae0db6ce2a01fdeb4a11221.Dv3G7SN4YTJgzY4l_Wu1y3XuM3gwcGvK0tV5WMDq0nUwarehouse-suggestions-suggested-models-strip--materialize-dialog-longer-schedule-unknown-sources--light:- hash: v1.k794b7964.5872f82618605205a3fde796088db08326f237543eae5f33711f0a30baf2cb77.lcVZNPKUrhhwlcL8UX95J6FdDkhsNmg0aLPRdTrMXk4+ hash: v1.k794b7964.0f6806dc8fbf944d32de7a93a9923d99e49eb8799d1f4fc0d23a6e6ce3cdf6f2.3Mhy6e_YfeA5cqAuT-IoGajBOBBd7Xdsn9wj1ZWWP5wwarehouse-suggestions-suggested-models-strip--not-eligible--dark:hash: v1.k794b7964.b646d37c91e92fd3d0053e1407559117a50c06c45f8ff7f4bcaaed18bab1cfef.1vguAxzgXrCyuyN1v2jRBSTSGDrmsu62f3nO60GFvGcwarehouse-suggestions-suggested-models-strip--not-eligible--light:hash: v1.k794b7964.a66ac5be916b459b6f8b15621e3bdeb12226d34c1e24feb15900940652fc238b.gzxwnKSQkZQfg5wdIMriKJO-aaxIteiXVzfSx1R7w8cwarehouse-suggestions-suggested-models-strip--review-dialog--dark:- hash: v1.k794b7964.d7a97db72786b603d2b91bc135306d9f209cb826b9a94ea60278e32a5b51c2b4.9SG-h8azE_3Dv6B0fRMypQwublXXHhEAhEtkTHy-ZPY+ hash: v1.k794b7964.d7281956d6a6d9500df44c8505e89d4a3a2741e69315d6662cc393c385dcdfac.PIDsknoPIZcTNh5840COUHo2Lgpi2L114i_1g-8aWQcwarehouse-suggestions-suggested-models-strip--review-dialog--light:- hash: v1.k794b7964.395fbaf1ad8d74c5063132bfeafe6a3f8f9130129e65b08687517c22b7430f79.t1FqX63N7P6Gyob_yJGn4aGFbsk_sMOJaXct-oJe98s+ hash: v1.k794b7964.8d03834be6be77e9fa4da3bf3e86fdd5364c0300a636ff6320ebc1e36aba2ab6.ItiXQCCUfNoe1z2aeuaXltIeUu3AdNgCglj6O0vYP2cwarehouse-suggestions-suggested-models-strip--review-dialog-many-suggestions--dark:- hash: v1.k794b7964.1fb2c3524d2880a401435332be82e9d6a109699bb684e8d8a632e2c1d7262cce.E6wFW05wsOdqs4abb8a7sOrqAiSlZD_2HGrqLHw8QpA+ hash: v1.k794b7964.df444e3dda3ca63b178c15440c87b97e0acf9c562cc143f66071e84e7e8cadab.VHVGDerYpYEiTemqHE__doI0aiCHhtYA5jOKjig6Feswarehouse-suggestions-suggested-models-strip--review-dialog-many-suggestions--light:- hash: v1.k794b7964.c441546b521c5286469dc57b0d4a1daedcceb71a1d1b77cc13a985d24a7bc0b2.RZP2_X7ud-iKHkrc4_5kNUPdG_Y7K9g_atrRdloUv9U+ hash: v1.k794b7964.75542fd854ab00627b79b61eb91c531f9a66177aa596f43128f56e8bbfaa6305.r54lMWbzjAt6mU4Tb4wbtQtP0Pok3jNpn_ENQYgk7Zowarehouse-suggestions-suggested-models-strip--review-dialog-viewer-without-edit-access--dark:- hash: v1.k794b7964.78818080e410c0639744c301e983042c6c5ce24e451eabe2c716df45d2988472.v_up3Pez-pWEw5UA_54ptbBwA470-3wcjOzaBOkOGk8+ hash: v1.k794b7964.2c87edc2f08ccb22d0cf99f5da81ff8af9d9d671aeaf69660f141c55109899d8.GeV--pV6uq1BCKojjyd-ZyGtRvnQhUiZ_4nZzXPTWSwwarehouse-suggestions-suggested-models-strip--review-dialog-viewer-without-edit-access--light:- hash: v1.k794b7964.62361ba9d4282173b78fc84a73210eb0b4df37902b6bd49ac341fdd520c3eaba.OPI08CUPtrsmvWyrvyjiojYy0k7xfjxGqLCkwbOP4_A+ hash: v1.k794b7964.bdd1546b1dbf5ea2bd54daecd79393039cc829a9f45f3982f518a3cc62790e22._UaFRRY155i2kx7xUMV9D-f2RdkTiYzT5XR4LNAM0YAwarehouse-suggestions-suggested-models-strip--stop-materializing-dialog--dark:- hash: v1.k794b7964.8a797fd358479a7be6614b6d85ebd369a80c839cf2d13f66458757bbb819772e.dG-gaGw-FHj4Gc2e68Y1vaLtxC1cfsC5ViVgLmLPNjk+ hash: v1.k794b7964.c59a50b5effd37216385a041de8fc64779bf250c284ac4333bd448dad326ea2f.AyjUcsLu5aIG9b7DQ0SHo0IcVbYDju5e8TMT65_dSO0warehouse-suggestions-suggested-models-strip--stop-materializing-dialog--light:- hash: v1.k794b7964.3fffc0e8f8756eeeb6073e1915247aa46a925e4cee1c15ddfbf15ceb188bbd8f.Gs-ybZLuvEAOo39xjwrpGnF-c8X-Zrjstj9gmTp3e1w+ hash: v1.k794b7964.ff1705f7ffddfcce15d27b15b4c105b29f7743d2f3584edd7a5de2dd87066882.eNjSCnNSrBfujqxMYzk0yXuaUyVHDNRmL_VIvLpiJRMwarehouse-suggestions-suggested-models-strip--warming-up--dark:hash: v1.k794b7964.860407091149fedd6c4e056cda79d92213e59dd9e00886e0cedee320fc267c48.x5QcsRUSRT66uOc237oq_n4D-eQWpY2GzsTRTC-SL6wwarehouse-suggestions-suggested-models-strip--warming-up--light:diff --git a/products/warehouse_suggestions/backend/facade/api.py b/products/warehouse_suggestions/backend/facade/api.pyindex aa7521a208fb..b909bb02bf1f 100644--- a/products/warehouse_suggestions/backend/facade/api.py+++ b/products/warehouse_suggestions/backend/facade/api.py@@ -5,6 +5,9 @@ from dataclasses import asdictfrom typing import TYPE_CHECKINGfrom uuid import UUID+from products.warehouse_sources.backend.facade.api import source_locations_for_tables+from products.warehouse_sources.backend.facade.contracts import TableSourceLocation+from ..logic import accept, suggestionsfrom ..logic.access import SubjectAccess, readable_table_ids, visible_suggestionsfrom ..logic.analytics import SuggestionOutcome, report_outcomes@@ -216,10 +219,19 @@ def _to_contracts(row.id: payload_from_json(WarehouseSuggestionKind(row.kind), row.payload_version, row.payload) for row in rows}readable = readable_table_ids(team_id, user_access_control, source_table_ids(stored.values()))- return [_to_contract(row, access, payload_view(stored[row.id], readable)) for row in rows]+ table_ids = {row.subject_id for row in rows if row.subject_kind == WarehouseSuggestionSubjectKind.TABLE}+ locations = source_locations_for_tables(team_id, table_ids)+ return [+ _to_contract(row, access, payload_view(stored[row.id], readable), locations.get(row.subject_id)) for row in rows+ ]-def _to_contract(row: WarehouseSuggestion, access: SubjectAccess, payload: SuggestionPayloadView) -> Suggestion:+def _to_contract(+ row: WarehouseSuggestion,+ access: SubjectAccess,+ payload: SuggestionPayloadView,+ location: TableSourceLocation | None,+) -> Suggestion:return Suggestion(id=row.id,kind=WarehouseSuggestionKind(row.kind),@@ -242,6 +254,8 @@ def _to_contract(row: WarehouseSuggestion, access: SubjectAccess, payload: Suggerealized_seconds_saved_per_month=row.realized_seconds_saved_per_month,realized_bytes_saved_per_month=row.realized_bytes_saved_per_month,can_act=access.can_act_on(row),+ subject_source_id=location.source_id if location else None,+ subject_schema_id=location.schema_id if location else None,)diff --git a/products/warehouse_suggestions/backend/facade/contracts.py b/products/warehouse_suggestions/backend/facade/contracts.pyindex 6a062ad5f5d4..8e74b46afcdf 100644--- a/products/warehouse_suggestions/backend/facade/contracts.py+++ b/products/warehouse_suggestions/backend/facade/contracts.py@@ -151,6 +151,8 @@ class Suggestion:realized_seconds_saved_per_month: float | Nonerealized_bytes_saved_per_month: float | Nonecan_act: bool+ subject_source_id: UUID | None = None+ subject_schema_id: UUID | None = None@frozendiff --git a/products/warehouse_suggestions/backend/presentation/serializers.py b/products/warehouse_suggestions/backend/presentation/serializers.pyindex 3e918c11ce0b..991f824432c3 100644--- a/products/warehouse_suggestions/backend/presentation/serializers.py+++ b/products/warehouse_suggestions/backend/presentation/serializers.py@@ -280,6 +280,14 @@ class WarehouseSuggestionSerializer(DataclassSerializer):"can_act": {"help_text": "Whether the caller has edit access to the subject and so may accept, dismiss or resume."},+ "subject_source_id": {+ "help_text": "Warehouse source that syncs the subject table, for linking to its schema page. Null for "+ "views and for tables no source syncs."+ },+ "subject_schema_id": {+ "help_text": "Source schema that syncs the subject table, for linking to its schema page. Null for "+ "views and for tables no source syncs."+ },}diff --git a/products/warehouse_suggestions/backend/tests/test_api.py b/products/warehouse_suggestions/backend/tests/test_api.pyindex aceb10f24cc9..1836524f06e5 100644--- a/products/warehouse_suggestions/backend/tests/test_api.py+++ b/products/warehouse_suggestions/backend/tests/test_api.py@@ -19,7 +19,7 @@ from posthog.models.utils import generate_random_token_personal, hash_key_valuefrom products.access_control.backend.models.access_control import AccessControlfrom products.data_modeling.backend.facade.models import DataWarehouseSavedQuery-from products.warehouse_sources.backend.facade.models import DataWarehouseTable+from products.warehouse_sources.backend.facade.models import DataWarehouseTable, ExternalDataSchema, ExternalDataSourcefrom products.warehouse_suggestions.backend.facade.contracts import (DeprecatePayload,MaterializePayload,@@ -130,6 +130,8 @@ class TestWarehouseSuggestionAPI(APIBaseTest):)def test_list_dismiss_and_resume(self) -> None:+ source = ExternalDataSource.objects.create(team=self.team, source_type="Stripe")+ schema = ExternalDataSchema.objects.create(team=self.team, source=source, table=self.table, name="charges")low = self._suggest(self.view.id, score=2.0)high = self._suggest(self.table.id, subject_kind=WarehouseSuggestionSubjectKind.TABLE, score=9.0)unmaterialize = ingest_surfaced(@@ -157,6 +159,11 @@ class TestWarehouseSuggestionAPI(APIBaseTest):assert rows[str(unmaterialize.id)]["payload"]["read_seconds"] == 5.0assert "query_fingerprint" not in rows[str(unmaterialize.id)]["payload"]assert all(row["can_act"] for row in listed.json()["results"])+ assert (rows[str(high.id)]["subject_source_id"], rows[str(high.id)]["subject_schema_id"]) == (+ str(source.id),+ str(schema.id),+ )+ assert (rows[str(low.id)]["subject_source_id"], rows[str(low.id)]["subject_schema_id"]) == (None, None)dismissed = self.client.post(f"{self.url}/{low.id}/dismiss/",diff --git a/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsxindex cab722821cd8..7fed4d48539d 100644--- a/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsx+++ b/products/warehouse_suggestions/frontend/components/CertificationSuggestionRow.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import { IconCheckCircle, IconWarning } from '@posthog/icons'-import { LemonButton, Link, Tooltip } from '@posthog/lemon-ui'+import { LemonButton, Tooltip } from '@posthog/lemon-ui'import { userHasAccess } from 'lib/utils/accessControlUtils'@@ -9,11 +9,11 @@ import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'import { AccessControlLevel, AccessControlResourceType } from '~/types'import type { WarehouseSuggestionApi } from '../generated/api.schemas'-import { subjectUrl } from '../subjectUrl'import { daysReadLabel, isDeprecatePayload, noReadsLabel, readSummary, refreshCostLabel } from '../suggestionCopy'import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'import { DismissSuggestionMenu } from './DismissSuggestionMenu'import { SuggestionRow } from './SuggestionRow'+import { SuggestionSubjectLink } from './SuggestionSubjectLink'import { WhyThisSuggestion } from './WhyThisSuggestion'const EDIT_ACCESS_REASON = 'You need edit access to this view or table'@@ -51,11 +51,7 @@ export function CertificationSuggestionRow({ suggestion, windowDays }: Certifica</span></Tooltip>}- title={- <Link to={subjectUrl(suggestion)} subtle className="block min-w-0 truncate text-sm font-semibold">- {payload.subject_name}- </Link>- }+ title={<SuggestionSubjectLink suggestion={suggestion} />}meta={deprecating? [diff --git a/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsxindex 53c79c5293ba..9c13bb55ea16 100644--- a/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx+++ b/products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx@@ -1,8 +1,6 @@import { useActions, useValues } from 'kea'-import { LemonButton, Link } from '@posthog/lemon-ui'--import { urls } from 'scenes/urls'+import { LemonButton } from '@posthog/lemon-ui'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'@@ -12,6 +10,7 @@ import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'import { DataAgeMeta } from './DataAgeMeta'import { DismissSuggestionMenu } from './DismissSuggestionMenu'import { SuggestionRow } from './SuggestionRow'+import { SuggestionSubjectLink } from './SuggestionSubjectLink'import { WhyThisSuggestion } from './WhyThisSuggestion'const EDIT_ACCESS_REASON = 'You need edit access to this view'@@ -43,15 +42,7 @@ export function MaterializeSuggestionRow({suggestionId={suggestion.id}leaving={leaving}icon={iconForType('data_modeling')}- title={- <Link- to={urls.sqlEditor({ view_id: suggestion.subject_id })}- subtle- className="block min-w-0 truncate text-sm font-semibold"- >- {payload.subject_name}- </Link>- }+ title={<SuggestionSubjectLink suggestion={suggestion} />}meta={[<WhyThisSuggestionkey="reads"diff --git a/products/warehouse_suggestions/frontend/components/SavingsBannerMessage.tsx b/products/warehouse_suggestions/frontend/components/SavingsBannerMessage.tsxindex 70958eeb2824..4d6504b68dc5 100644--- a/products/warehouse_suggestions/frontend/components/SavingsBannerMessage.tsx+++ b/products/warehouse_suggestions/frontend/components/SavingsBannerMessage.tsx@@ -1,24 +1,20 @@-import { humanizeBytes } from 'lib/utils/numbers'--import { SavingsSummary, countOf, spokenDuration } from '../suggestionCopy'+import { SavingsSummary, countOf, namedSaving } from '../suggestionCopy'export interface SavingsBannerMessageProps {summary: SavingsSummary}export function SavingsBannerMessage({ summary }: SavingsBannerMessageProps): JSX.Element {- const views = summary.timeViews + summary.bytesViews- const time = summary.timeViews > 0 ? `~${spokenDuration(summary.savedSeconds, 1)}` : null- const bytes = summary.bytesViews > 0 ? humanizeBytes(summary.savedBytes) : null+ const { time, bytes } = namedSaving(summary.saving, 1)return (<>- <strong translate="no">{countOf(views, 'view', 'views')}</strong>+ <strong translate="no">{countOf(summary.views, 'view', 'views')}</strong><span> could save </span>{time && (<><strong translate="no" className="text-success">- {time}+ {`~${time}`}</strong><span> of query time</span></>diff --git a/products/warehouse_suggestions/frontend/components/SuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/SuggestionRow.tsxindex 449f43238b8e..cf48f42192cd 100644--- a/products/warehouse_suggestions/frontend/components/SuggestionRow.tsx+++ b/products/warehouse_suggestions/frontend/components/SuggestionRow.tsx@@ -2,7 +2,9 @@ import { ReactNode } from 'react'import { cn } from 'lib/utils/css-classes'-import type { SavingHighlight } from '../suggestionCopy'+import { COMBINED_SAVING_LABEL, SavingHighlight } from '../suggestionCopy'++const AMOUNT_CLASS = 'text-sm font-semibold tabular-nums text-success'export interface SuggestionRowProps {suggestionId: string@@ -34,31 +36,44 @@ export function SuggestionRow({<div className="min-h-0 overflow-hidden"><divclassName={cn(- 'grid items-center gap-x-3 gap-y-1.5 px-3 py-2.5',+ 'grid grid-cols-1 gap-y-2 px-3 py-2.5 @min-[36rem]/suggestions:items-center @min-[36rem]/suggestions:gap-x-3',highlight- ? 'grid-cols-[minmax(0,1fr)_auto] @min-[36rem]/suggestions:grid-cols-[minmax(0,1fr)_10rem_minmax(15rem,auto)]'- : 'grid-cols-[minmax(0,1fr)_auto]'+ ? '@min-[36rem]/suggestions:grid-cols-[minmax(0,1fr)_10rem_minmax(15rem,auto)]'+ : '@min-[36rem]/suggestions:grid-cols-[minmax(0,1fr)_auto]')}>- <div- className={cn(- 'flex min-w-0 items-start gap-2',- highlight && 'col-span-2 @min-[36rem]/suggestions:col-span-1'- )}- >+ <div className="flex min-w-0 items-start gap-2"><span className="group/colorful-product-icons colorful-product-icons-true flex h-5 shrink-0 translate-y-0.5 items-center text-base">{icon}</span><div className="flex min-w-0 flex-col gap-0.5"><div className="flex min-w-0">{title}</div>- <div className="flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-secondary">- {meta.map((item, index) => (- <span key={index} className="inline-flex items-baseline gap-1.5">- {index > 0 && (+ {highlight && (+ <div className="flex flex-wrap items-baseline gap-x-1.5 @min-[36rem]/suggestions:hidden">+ <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>+ </div>+ )}+ <div className="flex flex-wrap items-baseline gap-x-4 gap-y-0.5 overflow-hidden text-xs text-secondary">+ {meta.map((item, index) => (+ <span key={index} className="-ml-4 inline-flex items-baseline">+ <span aria-hidden className="w-4 shrink-0 text-center text-muted">+ ·+ </span>{item}</span>))}@@ -66,14 +81,22 @@ export function SuggestionRow({</div></div>{highlight && (- <div className="flex min-w-0 items-baseline gap-1.5 @min-[36rem]/suggestions:flex-col @min-[36rem]/suggestions:items-end @min-[36rem]/suggestions:gap-0">- <span translate="no" className="text-sm font-semibold tabular-nums text-success">+ <div className="hidden min-w-0 flex-col items-end @min-[36rem]/suggestions:flex">+ <span translate="no" className={AMOUNT_CLASS}>{highlight.amount}</span><span className="text-xs text-secondary">{highlight.label}</span>+ {highlight.bytes && (+ <span translate="no" className="text-xs tabular-nums text-secondary">+ {`${highlight.bytes.amount} ${highlight.bytes.label}`}+ </span>+ )}</div>)}- <div data-suggestion-actions className="flex flex-wrap items-center justify-end gap-1">+ <div+ data-suggestion-actions+ className="flex flex-wrap items-center gap-1 pl-6 @min-[36rem]/suggestions:justify-end @min-[36rem]/suggestions:pl-0"+ >{actions}</div></div>diff --git a/products/warehouse_suggestions/frontend/components/SuggestionSubjectLink.tsx b/products/warehouse_suggestions/frontend/components/SuggestionSubjectLink.tsxnew file mode 100644index 000000000000..e51281ef79c3--- /dev/null+++ b/products/warehouse_suggestions/frontend/components/SuggestionSubjectLink.tsx@@ -0,0 +1,23 @@+import { Link } from '@posthog/lemon-ui'++import type { WarehouseSuggestionApi } from '../generated/api.schemas'+import { subjectUrl } from '../subjectUrl'++export interface SuggestionSubjectLinkProps {+ suggestion: WarehouseSuggestionApi+}++export function SuggestionSubjectLink({ suggestion }: SuggestionSubjectLinkProps): JSX.Element {+ return (+ <Link+ to={subjectUrl(suggestion)}+ target="_blank"+ targetBlankIcon+ subtle+ className="inline-flex min-w-0 items-center gap-1 text-sm font-semibold"+ >+ <span className="truncate">{suggestion.payload.subject_name}</span>+ <span className="sr-only"> (opens in a new tab)</span>+ </Link>+ )+}diff --git a/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionModal.tsx b/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionModal.tsxindex 1b67c8945f31..5b4efec16311 100644--- a/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionModal.tsx+++ b/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionModal.tsx@@ -6,7 +6,6 @@ import {isUnmaterializePayload,monthlyCost,readTimeLabel,- savesTime,savingSentence,unmaterializeSaving,} from '../suggestionCopy'@@ -22,7 +21,6 @@ export function UnmaterializeSuggestionModal(): JSX.Element | null {}const inFlight = !!actionsInFlight[acceptConfirmSuggestion.id]const saving = unmaterializeSaving(payload)- const inTime = savesTime(saving)return (<LemonModal@@ -59,13 +57,16 @@ export function UnmaterializeSuggestionModal(): JSX.Element | null {<div className="flex flex-col gap-0.5"><span className="text-xs font-semibold text-secondary">Materialized now</span><span className="text-sm">- {monthlyCost(payload.refresh_seconds_per_month, payload.refresh_bytes_per_month, inTime)}+ {monthlyCost({+ seconds: payload.refresh_seconds_per_month,+ bytes: payload.refresh_bytes_per_month,+ })}</span></div><div className="flex flex-col gap-0.5"><span className="text-xs font-semibold text-secondary">Computed on each read</span><span className="text-sm">- {`${monthlyCost(payload.live_seconds_per_month, payload.live_bytes_per_month, inTime)} (estimate)`}+ {`${monthlyCost({ seconds: payload.live_seconds_per_month, bytes: payload.live_bytes_per_month })} (estimate)`}</span><span className="text-xs text-secondary">{readTimeLabel(payload.read_seconds)}</span></div>diff --git a/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx b/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsxindex e5f938dbe662..aeed86cc3297 100644--- a/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx+++ b/products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx@@ -1,8 +1,6 @@import { useActions, useValues } from 'kea'-import { LemonButton, Link } from '@posthog/lemon-ui'--import { urls } from 'scenes/urls'+import { LemonButton } from '@posthog/lemon-ui'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'@@ -17,6 +15,7 @@ import {import { warehouseSuggestionsLogic } from '../warehouseSuggestionsLogic'import { DismissSuggestionMenu } from './DismissSuggestionMenu'import { SuggestionRow } from './SuggestionRow'+import { SuggestionSubjectLink } from './SuggestionSubjectLink'import { WhyThisSuggestion } from './WhyThisSuggestion'const EDIT_ACCESS_REASON = 'You need edit access to this view'@@ -48,15 +47,7 @@ export function UnmaterializeSuggestionRow({suggestionId={suggestion.id}leaving={leaving}icon={iconForType('data_modeling')}- title={- <Link- to={urls.sqlEditor({ view_id: suggestion.subject_id })}- subtle- className="block min-w-0 truncate text-sm font-semibold"- >- {payload.subject_name}- </Link>- }+ title={<SuggestionSubjectLink suggestion={suggestion} />}meta={[<WhyThisSuggestionkey="reads"diff --git a/products/warehouse_suggestions/frontend/generated/api.schemas.ts b/products/warehouse_suggestions/frontend/generated/api.schemas.tsindex dfccc10aa11e..2b43f0ec9c93 100644--- a/products/warehouse_suggestions/frontend/generated/api.schemas.ts+++ b/products/warehouse_suggestions/frontend/generated/api.schemas.ts@@ -314,6 +314,16 @@ export interface WarehouseSuggestionApi {realized_bytes_saved_per_month: number | null/** Whether the caller has edit access to the subject and so may accept, dismiss or resume. */can_act: boolean+ /**+ * Warehouse source that syncs the subject table, for linking to its schema page. Null for views and for tables no source syncs.+ * @nullable+ */+ subject_source_id?: string | null+ /**+ * Source schema that syncs the subject table, for linking to its schema page. Null for views and for tables no source syncs.+ * @nullable+ */+ subject_schema_id?: string | null}export interface PaginatedWarehouseSuggestionListApi {diff --git a/products/warehouse_suggestions/frontend/subjectUrl.test.ts b/products/warehouse_suggestions/frontend/subjectUrl.test.tsindex 632e988d901b..61920ed927cd 100644--- a/products/warehouse_suggestions/frontend/subjectUrl.test.ts+++ b/products/warehouse_suggestions/frontend/subjectUrl.test.ts@@ -1,29 +1,45 @@import type { WarehouseSuggestionApi } from './generated/api.schemas'import { subjectUrl } from './subjectUrl'-function tableSuggestion(name: string): WarehouseSuggestionApi {+function suggestion(overrides: Partial<WarehouseSuggestionApi>): WarehouseSuggestionApi {return {kind: 'certify',subject_kind: 'table',subject_id: 'table-1',- payload: { subject_name: name },+ subject_source_id: null,+ subject_schema_id: null,+ payload: { subject_name: 'stripe_charges' },+ ...overrides,} as WarehouseSuggestionApi}-function previewQuery(url: string): string | null {- return new URL(url, 'https://example.com').searchParams.get('open_query')-}-describe('subjectUrl', () => {- it.each([- ['a plain table name', 'stripe_charges', 'SELECT * FROM stripe_charges LIMIT 100'],- ['a dotted source table name', 'demo.orders', 'SELECT * FROM demo.orders LIMIT 100'],+ it.each<[string, WarehouseSuggestionApi, Parameters<typeof subjectUrl>[1], string]>([+ [+ 'a view on its model page',+ suggestion({ subject_kind: 'saved_query', subject_id: 'view-1' }),+ undefined,+ '/models/view-1?lookup=saved_query',+ ],+ [+ 'a view on the model tab it was asked for',+ suggestion({ subject_kind: 'saved_query', subject_id: 'view-1' }),+ 'materialization',+ '/models/view-1/materialization?lookup=saved_query',+ ],+ [+ 'a synced table on its source schema page',+ suggestion({ subject_source_id: 'source-1', subject_schema_id: 'schema-1' }),+ undefined,+ '/data-management/sources/managed-source-1/schemas/schema-1',+ ],[- 'a stored name that starts and ends with quotes',- '"x" UNION SELECT * FROM persons --"',- 'SELECT * FROM `"x" UNION SELECT * FROM persons --"` LIMIT 100',+ 'a table no source syncs on its own source page',+ suggestion({}),+ undefined,+ '/data-management/sources/self-managed-table-1/schemas',],- ])('previews %s as one table', (_name, tableName, query) => {- expect(previewQuery(subjectUrl(tableSuggestion(tableName)))).toEqual(query)+ ])('opens %s', (_name, input, tab, url) => {+ expect(subjectUrl(input, tab)).toEqual(url)})})diff --git a/products/warehouse_suggestions/frontend/subjectUrl.ts b/products/warehouse_suggestions/frontend/subjectUrl.tsindex 99d9341b79bd..817fb9e4ef7a 100644--- a/products/warehouse_suggestions/frontend/subjectUrl.ts+++ b/products/warehouse_suggestions/frontend/subjectUrl.ts@@ -1,19 +1,19 @@-import { urls } from 'scenes/urls'+import { combineUrl } from 'kea-router'-import { escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'+import { urls } from 'scenes/urls'import type { WarehouseSuggestionApi } from './generated/api.schemas'-const TABLE_PREVIEW_LIMIT = 100+type ModelPageTab = Parameters<typeof urls.nodeDetail>[1]-function escapeTableName(name: string): string {- return name.split('.').map(escapeRawPropertyAsHogQLIdentifier).join('.')-}+const SAVED_QUERY_LOOKUP = { lookup: 'saved_query' }-export function subjectUrl(suggestion: WarehouseSuggestionApi): string {- if (suggestion.subject_kind === 'table') {- const table = escapeTableName(suggestion.payload.subject_name)- return urls.sqlEditor({ query: `SELECT * FROM ${table} LIMIT ${TABLE_PREVIEW_LIMIT}` })+export function subjectUrl(suggestion: WarehouseSuggestionApi, tab?: ModelPageTab): string {+ if (suggestion.subject_kind === 'saved_query') {+ return combineUrl(urls.nodeDetail(suggestion.subject_id, tab), SAVED_QUERY_LOOKUP).url+ }+ if (suggestion.subject_source_id && suggestion.subject_schema_id) {+ return urls.dataWarehouseSourceSchema(`managed-${suggestion.subject_source_id}`, suggestion.subject_schema_id)}- return urls.sqlEditor({ view_id: suggestion.subject_id })+ return urls.dataWarehouseSource(`self-managed-${suggestion.subject_id}`)}diff --git a/products/warehouse_suggestions/frontend/suggestionCopy.test.ts b/products/warehouse_suggestions/frontend/suggestionCopy.test.tsindex d497ea487c2f..dbb54e42b733 100644--- a/products/warehouse_suggestions/frontend/suggestionCopy.test.ts+++ b/products/warehouse_suggestions/frontend/suggestionCopy.test.ts@@ -1,14 +1,20 @@import type { WarehouseSuggestionMaterializePayloadApi } from './generated/api.schemas'import {+ MonthlySaving,+ SavingHighlight,UNKNOWN_SOURCES_CAVEAT,dataAgeLabel,notNowCondition,+ savingHighlight,+ savingSentence,suggestedScheduleHint,todayAgeLabel,} from './suggestionCopy'const DAY = 24 * 60 * 60const HOUR = 60 * 60+const MB = 1024 ** 2+const TB = 1024 ** 4function payload(freshnessTodaySeconds: number | null,@@ -44,6 +50,34 @@ describe('suggestionCopy', () => {expect(todayAgeLabel(input)).toEqual(today)})+ it.each<[string, MonthlySaving, SavingHighlight, string]>([+ [+ 'time and bytes',+ { seconds: 17 * 60, bytes: 3.2 * TB },+ {+ amount: '~17 minutes',+ label: 'query time saved a month',+ bytes: { amount: '~3.20 TB', label: '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' },+ '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' },+ 'Saves about 40.00 MB of scanning a month',+ ],+ ])('names every saving worth naming when a suggestion saves %s', (_name, saving, highlight, sentence) => {+ expect(savingHighlight(saving)).toEqual(highlight)+ expect(savingSentence(saving)).toEqual(sentence)+ })+it.each<[Parameters<typeof suggestedScheduleHint>[0], string]>([['source_sync', "sources don't sync more often"],['read_rate', "People don't read it more often"],diff --git a/products/warehouse_suggestions/frontend/suggestionCopy.ts b/products/warehouse_suggestions/frontend/suggestionCopy.tsindex 0dac0c8286ea..8294c48ecaaa 100644--- a/products/warehouse_suggestions/frontend/suggestionCopy.ts+++ b/products/warehouse_suggestions/frontend/suggestionCopy.ts@@ -10,6 +10,7 @@ import type {} from './generated/api.schemas'const MIN_SECONDS_WORTH_NAMING = 60+const MIN_BYTES_WORTH_NAMING = 1024 ** 3const SPOKEN_UNITS: [string, number][] = [['day', 24 * 60 * 60],['hour', 60 * 60],@@ -31,12 +32,17 @@ const SURFACE_LABELS: Record<string, string> = {}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 SavingHighlight {+export interface SavingAmount {amount: stringlabel: string}+export interface SavingHighlight extends SavingAmount {+ bytes?: SavingAmount+}+export interface SurfaceSegment {key: stringlabel: string@@ -44,10 +50,8 @@ export interface SurfaceSegment {}export interface SavingsSummary {- timeViews: number- savedSeconds: number- bytesViews: number- savedBytes: number+ views: number+ saving: MonthlySaving}export interface MonthlySaving {@@ -55,6 +59,11 @@ export interface MonthlySaving {bytes: number}+export interface NamedSaving {+ time: string | null+ bytes: string | null+}+export interface DataAgeLabel {label: stringcaveat: string | null@@ -100,6 +109,12 @@ export function savesTime(saving: MonthlySaving): boolean {return saving.seconds >= MIN_SECONDS_WORTH_NAMING}+export function namedSaving(saving: MonthlySaving, maxUnits: number): NamedSaving {+ const time = savesTime(saving) ? spokenDuration(saving.seconds, maxUnits) : null+ const bytes = !time || saving.bytes >= MIN_BYTES_WORTH_NAMING ? humanizeBytes(saving.bytes) : null+ return { time, bytes }+}+export function suggestedScheduleHint(basis: WarehouseSuggestionRefreshIntervalBasisEnumApi | null,cadence: string@@ -140,23 +155,29 @@ export function refreshModeLabel(incremental: boolean, incrementalKey: string |}export function savingHighlight(saving: MonthlySaving): SavingHighlight {- if (savesTime(saving)) {- return { amount: `~${spokenDuration(saving.seconds, 1)}`, label: 'query time saved a month' }+ const { time, bytes } = namedSaving(saving, 1)+ if (!time) {+ return { amount: `~${bytes}`, label: 'less data scanned a month' }+ }+ return {+ amount: `~${time}`,+ label: 'query time saved a month',+ ...(bytes ? { bytes: { amount: `~${bytes}`, label: 'less scanned' } } : {}),}- return { amount: `~${humanizeBytes(saving.bytes)}`, label: 'less data scanned a month' }}export function savingSentence(saving: MonthlySaving): string {- if (savesTime(saving)) {- return `Saves about ${spokenDuration(saving.seconds, 1)} of query time a month`- }- return `Saves about ${humanizeBytes(saving.bytes)} of scanning a month`+ const { time, bytes } = namedSaving(saving, 1)+ const parts = [time && `${time} of query time`, bytes && `${bytes} of scanning`].filter(Boolean)+ return `Saves about ${parts.join(' and ')} a month`}-export function monthlyCost(seconds: number, bytes: number, inTime: boolean): string {- return inTime- ? `about ${spokenDuration(seconds, MAX_SPOKEN_UNITS)} a month`- : `about ${humanizeBytes(bytes)} scanned a month`+export function monthlyCost(cost: MonthlySaving): string {+ const { time, bytes } = namedSaving(cost, MAX_SPOKEN_UNITS)+ if (!time) {+ return `about ${bytes} scanned a month`+ }+ return bytes ? `about ${time} a month, scanning ${bytes}` : `about ${time} a month`}export function readTimeLabel(seconds: number): string {@@ -201,10 +222,14 @@ export function noReadsLabel(windowDays: number): string {export function refreshCostLabel(payload: Pick<WarehouseSuggestionDeprecatePayloadApi, 'refresh_seconds_per_month' | 'refresh_bytes_per_month'>): string {- if (payload.refresh_seconds_per_month >= MIN_SECONDS_WORTH_NAMING) {- return `Refreshes use about ${spokenDuration(payload.refresh_seconds_per_month, MAX_SPOKEN_UNITS)} a month`+ const { time, bytes } = namedSaving(+ { seconds: payload.refresh_seconds_per_month, bytes: payload.refresh_bytes_per_month },+ MAX_SPOKEN_UNITS+ )+ if (!time) {+ return `Refreshes scan about ${bytes} a month`}- return `Refreshes scan about ${humanizeBytes(payload.refresh_bytes_per_month)} a month`+ return bytes ? `Refreshes use about ${time} a month and scan ${bytes}` : `Refreshes use about ${time} a month`}function dataAgeAfterSeconds(payload: WarehouseSuggestionMaterializePayloadApi, intervalSeconds: number): number {diff --git a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.ts b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.tsindex 1d58c0db4256..4d26735d54c9 100644--- a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.ts+++ b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.test.ts@@ -503,17 +503,14 @@ describe('warehouseSuggestionsLogic', () => {expect(logic.values.surfaceSuggestions.map((suggestion) => suggestion.id)).toEqual(expectedOrder)})- it('counts time and bytes savings separately', async () => {- mockList.mockResolvedValue(page([materialize('a', 1800), materialize('b', 1200), materialize('c', 0, 3e12)]))+ it('sums time and bytes across every view, including views that save both', async () => {+ mockList.mockResolvedValue(+ page([materialize('a', 1800, 2e12), materialize('b', 1200), materialize('c', 0, 3e12)])+ )await mountLogic()- expect(logic.values.savingsSummary).toEqual({- timeViews: 2,- savedSeconds: 3000,- bytesViews: 1,- savedBytes: 3e12,- })+ expect(logic.values.savingsSummary).toEqual({ views: 3, saving: { seconds: 3000, bytes: 5e12 } })})it('drops an accepted row from the counts at once and from the list after it leaves', async () => {@@ -526,7 +523,7 @@ describe('warehouseSuggestionsLogic', () => {logic.actions.acceptSuggestion('a', { refresh_interval_seconds: 86400 })await expectLogic(logic).toDispatchActions(['suggestionAccepted'])- expect(logic.values.savingsSummary.savedSeconds).toEqual(1200)+ expect(logic.values.savingsSummary.saving.seconds).toEqual(1200)expect(logic.values.listedSuggestions.map((suggestion) => suggestion.id)).toEqual(['a', 'b'])jest.advanceTimersByTime(ROW_LEAVE_MS)@@ -658,12 +655,12 @@ describe('warehouseSuggestionsLogic', () => {}it.each([MATERIALIZE, unmaterialize('unread', 3000, 1500)])(- 'sends the strip toast View for $kind to the view in the SQL editor',+ 'sends the strip toast View for $kind to the materialization tab of its model page',async (accepted) => {await acceptAndClickView('models', accepted)expect(router.values.location.pathname + router.values.location.search).toContain(- urls.sqlEditor({ view_id: accepted.subject_id })+ `${urls.nodeDetail(accepted.subject_id, 'materialization')}?lookup=saved_query`)})diff --git a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.ts b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.tsindex 7f54afc17f03..76d066e637f1 100644--- a/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.ts+++ b/products/warehouse_suggestions/frontend/warehouseSuggestionsLogic.ts@@ -19,7 +19,6 @@ import { ApiConfig } from 'lib/api'import { ApiError } from 'lib/api-error'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { EMPTY_INCREMENTAL_DRAFT, IncrementalConfigDraft } from 'scenes/data-warehouse/editor/IncrementalConfigFields'-import { urls } from 'scenes/urls'import { DataModelingSyncInterval } from '~/types'@@ -45,6 +44,7 @@ import type {} from './generated/api.schemas'import type { WarehouseSuggestionDismissalReasonEnumApi } from './generated/api.schemas'import { INTERVAL_SECONDS, intervalForSeconds } from './refreshIntervals'+import { subjectUrl } from './subjectUrl'import {MonthlySaving,SavingsSummary,@@ -70,7 +70,7 @@ const SURFACE_KINDS: Record<SuggestionSurface, string[]> = {models: ['materialize', 'unmaterialize'],catalog: ['certify', 'deprecate'],}-const VIEW_IN_SQL_EDITOR_KINDS = ['materialize', 'unmaterialize']+const VIEW_ON_MODEL_PAGE_KINDS = ['materialize', 'unmaterialize']const CONFLICT_STATUS = 409const NOT_FOUND_STATUS = 404const FORBIDDEN_STATUS = 403@@ -591,13 +591,12 @@ export const warehouseSuggestionsLogic: LogicWrapper<warehouseSuggestionsLogicTyconst savings = open.map(({ payload }) => monthlySaving(payload)).filter((saving): saving is MonthlySaving => saving !== null)- const timeSavers = savings.filter(savesTime)- const bytesSavers = savings.filter((saving) => !savesTime(saving))return {- timeViews: timeSavers.length,- savedSeconds: sum(timeSavers.map((saving) => saving.seconds)),- bytesViews: bytesSavers.length,- savedBytes: sum(bytesSavers.map((saving) => saving.bytes)),+ views: savings.length,+ saving: {+ seconds: sum(savings.map((saving) => saving.seconds)),+ bytes: sum(savings.map((saving) => saving.bytes)),+ },}},],@@ -691,12 +690,12 @@ export const warehouseSuggestionsLogic: LogicWrapper<warehouseSuggestionsLogicTy})}const viewAction = (suggestion: WarehouseSuggestionApi): (() => void) | null => {- const opensInSqlEditor = VIEW_IN_SQL_EDITOR_KINDS.includes(suggestion.kind)- if (!opensInSqlEditor && !suggestion.created_asset?.certification_id) {+ const opensModelPage = VIEW_ON_MODEL_PAGE_KINDS.includes(suggestion.kind)+ if (!opensModelPage && !suggestion.created_asset?.certification_id) {return null}const onViewAccepted = props.onViewAccepted- if (!onViewAccepted && !opensInSqlEditor) {+ if (!onViewAccepted && !opensModelPage) {return null}return () => {@@ -705,7 +704,7 @@ export const warehouseSuggestionsLogic: LogicWrapper<warehouseSuggestionsLogicTyonViewAccepted(suggestion)return}- router.actions.push(urls.sqlEditor({ view_id: suggestion.subject_id }))+ router.actions.push(subjectUrl(suggestion, 'materialization'))}}return {diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 76501a5271ef..760864887abf 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -81589,6 +81589,16 @@ export namespace Schemas {realized_bytes_saved_per_month: number | null;/** Whether the caller has edit access to the subject and so may accept, dismiss or resume. */can_act: boolean;+ /**+ * Warehouse source that syncs the subject table, for linking to its schema page. Null for views and for tables no source syncs.+ * @nullable+ */+ subject_source_id?: string | null;+ /**+ * Source schema that syncs the subject table, for linking to its schema page. Null for views and for tables no source syncs.+ * @nullable+ */+ subject_schema_id?: string | null;}export interface PaginatedWarehouseSuggestionList {