mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
236 lines
7.6 KiB
TypeScript
236 lines
7.6 KiB
TypeScript
import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers, selectors } from 'kea'
|
|
import { loaders } from 'kea-loaders'
|
|
|
|
import { teamLogic } from 'scenes/teamLogic'
|
|
import { urls } from 'scenes/urls'
|
|
|
|
import { Breadcrumb } from '~/types'
|
|
|
|
import { identityMatchingLinksList, identityMatchingLinksRunsRetrieve } from './generated/api'
|
|
import type {
|
|
IdentityMatchingLinkApi,
|
|
IdentityMatchingLinksListParams,
|
|
IdentityMatchingLinksListTier,
|
|
IdentityMatchingLinksResponseApi,
|
|
IdentityMatchingRunApi,
|
|
IdentityMatchingRunsResponseApi,
|
|
} from './generated/api.schemas'
|
|
|
|
export interface IdentityMatchingFilters {
|
|
jobId: string | null
|
|
modelVersion: string | null
|
|
tier: IdentityMatchingLinksListTier | null
|
|
minScore: number | null
|
|
search: string
|
|
}
|
|
|
|
const DEFAULT_FILTERS: IdentityMatchingFilters = {
|
|
jobId: null,
|
|
modelVersion: null,
|
|
tier: null,
|
|
minScore: null,
|
|
search: '',
|
|
}
|
|
|
|
export const LINKS_PAGE_SIZE = 50
|
|
|
|
export type IdentityMatchingTab = 'links' | 'paid_attribution' | 'runs'
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface identityMatchingLogicValues {
|
|
activeTab: IdentityMatchingTab
|
|
breadcrumbs: Breadcrumb[]
|
|
filters: IdentityMatchingFilters
|
|
links: IdentityMatchingLinkApi[]
|
|
linksCount: number
|
|
linksResponse: IdentityMatchingLinksResponseApi | null
|
|
linksResponseLoading: boolean
|
|
modelVersions: string[]
|
|
page: number
|
|
runs: IdentityMatchingRunApi[]
|
|
runsResponse: IdentityMatchingRunsResponseApi | null
|
|
runsResponseLoading: boolean
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface identityMatchingLogicActions {
|
|
loadLinks: (_: unknown) => unknown
|
|
loadLinksFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
loadLinksSuccess: (
|
|
linksResponse: IdentityMatchingLinksResponseApi | null,
|
|
payload?: unknown
|
|
) => {
|
|
linksResponse: IdentityMatchingLinksResponseApi | null
|
|
payload?: unknown
|
|
}
|
|
loadRuns: () => any
|
|
loadRunsFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
loadRunsSuccess: (
|
|
runsResponse: IdentityMatchingRunsResponseApi,
|
|
payload?: any
|
|
) => {
|
|
runsResponse: IdentityMatchingRunsResponseApi
|
|
payload?: any
|
|
}
|
|
setActiveTab: (tab: IdentityMatchingTab) => {
|
|
tab: IdentityMatchingTab
|
|
}
|
|
setFilters: (filters: Partial<IdentityMatchingFilters>) => {
|
|
filters: Partial<IdentityMatchingFilters>
|
|
}
|
|
setPage: (page: number) => {
|
|
page: number
|
|
}
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface identityMatchingLogicMeta {
|
|
__keaTypeGenInternalSelectorTypes: {
|
|
links: (linksResponse: IdentityMatchingLinksResponseApi | null) => IdentityMatchingLinkApi[]
|
|
linksCount: (linksResponse: IdentityMatchingLinksResponseApi | null) => number
|
|
runs: (runsResponse: IdentityMatchingRunsResponseApi | null) => IdentityMatchingRunApi[]
|
|
modelVersions: (runs: IdentityMatchingRunApi[]) => string[]
|
|
}
|
|
}
|
|
|
|
export type identityMatchingLogicType = MakeLogicType<
|
|
identityMatchingLogicValues,
|
|
identityMatchingLogicActions,
|
|
Record<string, any>,
|
|
identityMatchingLogicMeta
|
|
>
|
|
|
|
export const identityMatchingLogic = kea<identityMatchingLogicType>([
|
|
path(['products', 'growth', 'frontend', 'identityMatchingLogic']),
|
|
actions({
|
|
setFilters: (filters: Partial<IdentityMatchingFilters>) => ({ filters }),
|
|
setPage: (page: number) => ({ page }),
|
|
setActiveTab: (tab: IdentityMatchingTab) => ({ tab }),
|
|
}),
|
|
loaders(({ values, cache }) => ({
|
|
runsResponse: {
|
|
__default: null as IdentityMatchingRunsResponseApi | null,
|
|
loadRuns: async () => {
|
|
const projectId = String(teamLogic.values.currentTeamId)
|
|
return await identityMatchingLinksRunsRetrieve(projectId)
|
|
},
|
|
},
|
|
linksResponse: {
|
|
__default: null as IdentityMatchingLinksResponseApi | null,
|
|
loadLinks: async (_: unknown, breakpoint) => {
|
|
await breakpoint(300)
|
|
const projectId = String(teamLogic.values.currentTeamId)
|
|
const { jobId, modelVersion, tier, minScore, search } = values.filters
|
|
const offset = (values.page - 1) * LINKS_PAGE_SIZE
|
|
const params: IdentityMatchingLinksListParams = { limit: LINKS_PAGE_SIZE, offset }
|
|
if (jobId) {
|
|
params.job_id = jobId
|
|
}
|
|
if (modelVersion) {
|
|
params.model_version = modelVersion
|
|
}
|
|
if (tier) {
|
|
params.tier = tier
|
|
}
|
|
if (minScore !== null) {
|
|
params.min_score = minScore
|
|
}
|
|
if (search.trim()) {
|
|
params.search = search.trim()
|
|
}
|
|
const requestId = (cache.loadLinksSeq = (cache.loadLinksSeq ?? 0) + 1)
|
|
const response = await identityMatchingLinksList(projectId, params)
|
|
breakpoint()
|
|
if (requestId !== cache.loadLinksSeq) {
|
|
return values.linksResponse
|
|
}
|
|
return response
|
|
},
|
|
},
|
|
})),
|
|
reducers({
|
|
filters: [
|
|
DEFAULT_FILTERS,
|
|
{
|
|
setFilters: (state, { filters }) => ({ ...state, ...filters }),
|
|
},
|
|
],
|
|
page: [
|
|
1,
|
|
{
|
|
setPage: (_, { page }) => page,
|
|
setFilters: () => 1,
|
|
},
|
|
],
|
|
activeTab: [
|
|
'links' as IdentityMatchingTab,
|
|
{
|
|
setActiveTab: (_, { tab }) => tab,
|
|
},
|
|
],
|
|
}),
|
|
selectors({
|
|
links: [
|
|
(s) => [s.linksResponse],
|
|
(linksResponse: IdentityMatchingLinksResponseApi | null): IdentityMatchingLinkApi[] =>
|
|
linksResponse?.results ?? [],
|
|
],
|
|
linksCount: [
|
|
(s) => [s.linksResponse],
|
|
(linksResponse: IdentityMatchingLinksResponseApi | null): number => linksResponse?.count ?? 0,
|
|
],
|
|
runs: [
|
|
(s) => [s.runsResponse],
|
|
(runsResponse: IdentityMatchingRunsResponseApi | null): IdentityMatchingRunApi[] =>
|
|
runsResponse?.results ?? [],
|
|
],
|
|
modelVersions: [
|
|
(s) => [s.runs],
|
|
(runs: IdentityMatchingRunApi[]): string[] => {
|
|
const versions = new Set<string>()
|
|
for (const run of runs) {
|
|
for (const model of run.models) {
|
|
versions.add(model.model_version)
|
|
}
|
|
}
|
|
return Array.from(versions).sort()
|
|
},
|
|
],
|
|
breadcrumbs: [
|
|
() => [],
|
|
(): Breadcrumb[] => [
|
|
{
|
|
key: 'IdentityMatching',
|
|
name: 'Identity matching',
|
|
path: urls.identityMatching(),
|
|
iconType: 'persons',
|
|
},
|
|
],
|
|
],
|
|
}),
|
|
listeners(({ actions }) => ({
|
|
setFilters: () => {
|
|
actions.loadLinks(null)
|
|
},
|
|
setPage: () => {
|
|
actions.loadLinks(null)
|
|
},
|
|
})),
|
|
afterMount(({ actions }) => {
|
|
actions.loadRuns()
|
|
actions.loadLinks(null)
|
|
}),
|
|
])
|