mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-03 00:52:32 +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.
59 lines
2.4 KiB
Python
59 lines
2.4 KiB
Python
"""Typed field registry for firmographic enrichment.
|
|
|
|
The single source of truth every enrichment writer imports, so the Postgres record,
|
|
the Datastore group-property projection, and the at-signup snapshot stay in lockstep.
|
|
Provider-agnostic: providers transform their responses into this shape. The ICP score is
|
|
deliberately not a field here: it is derived rather than provider-reported, and the writer
|
|
takes it separately so it stays out of the `fields_filled` launch signal.
|
|
|
|
Precedent: ee/billing/salesforce_enrichment/usage_signals.py (UsageSignals).
|
|
"""
|
|
|
|
import dataclasses
|
|
from typing import Any, Optional
|
|
|
|
# Prefix for the `enrichment_*` Datastore group properties written via group_identify.
|
|
ENRICHMENT_PROPERTY_PREFIX = "enrichment_"
|
|
|
|
# Fields whose provider source matches what already populates the icp_* group properties
|
|
# (Harmonic-first in the incumbent waterfall), so we write the same keys and consumers
|
|
# never migrate. Source-changing fields stay on the parallel `enrichment_*` namespace
|
|
# until they pass their own comparison.
|
|
SAME_KEY_GROUP_PROPERTIES: dict[str, str] = {
|
|
"headcount": "icp_employees",
|
|
"country": "icp_country",
|
|
}
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class EnrichmentFields:
|
|
"""Firmographic enrichment values for one organization."""
|
|
|
|
company_type: Optional[str] = None
|
|
headcount: Optional[int] = None
|
|
headcount_engineering: Optional[int] = None
|
|
industry: Optional[str] = None
|
|
country: Optional[str] = None
|
|
founded_year: Optional[int] = None
|
|
funding_stage: Optional[str] = None
|
|
total_raised: Optional[int] = None
|
|
last_round_size: Optional[int] = None
|
|
last_round_date: Optional[str] = None
|
|
investors: Optional[list[str]] = None
|
|
is_yc_company: Optional[bool] = None
|
|
is_ai_native: Optional[bool] = None
|
|
work_email: Optional[bool] = None
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
"""Return set (non-None) fields keyed by registry name."""
|
|
return {
|
|
field.name: value for field in dataclasses.fields(self) if (value := getattr(self, field.name)) is not None
|
|
}
|
|
|
|
def to_group_properties(self) -> dict[str, Any]:
|
|
"""Return the Datastore group properties: takeover fields on their icp_* keys, the rest as `enrichment_*`."""
|
|
return {
|
|
SAME_KEY_GROUP_PROPERTIES.get(name, f"{ENRICHMENT_PROPERTY_PREFIX}{name}"): value
|
|
for name, value in self.to_dict().items()
|
|
}
|