feat(scoring): 990-PF funder-precedent index — the 25-point subscore goes live
New funders/funder_grants schema + ingest990pf monthly workflow: IRS BMF state file discovers NH private foundations (747), e-file index CSVs select their latest 990-PF filings, batch ZIPs stream through fflate (4/run cap, most-hits-first, deferred logged), grants-paid rows land in funder_grants, and funders with >=2 NH grants synthesize rolling grant rows (source irs_990pf, funder_ein linked) that flow through the existing embed+match pipeline. Scoring v2: funderPrecedentSubscore tiers repeated in-state giving (1/3/5/10 -> 8/15/20/25); easy win = >=65 total AND >=12 precedent (plan's precedent floor); scale is the full 0-100. Rolling deadlines pass the runway gate. Retrieval computes per-funder in-state counts and exposes funder_ein. Lead-quality gates from the first precedent run's failures: candidate orgs exclude NTEE T* grantmakers; self-matches gated by EIN + normalized name (NHDOJ registers foundations as charities, several without resolved EINs — the first run's top 'leads' were foundations matched to themselves). Live: ~6.5GB of IRS batches processed, 2,766 grants-paid rows, 123 synthesized foundation grants, 89 easy wins across 27 orgs, credible top-10 (AIDS Response-Seacoast -> Foundation for Seacoast Health, 25/25 precedent). 153 tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
CREATE TABLE "funder_grants" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"funder_id" uuid NOT NULL,
|
||||
"recipient_name" text NOT NULL,
|
||||
"recipient_city" text,
|
||||
"recipient_state" text,
|
||||
"amount" integer,
|
||||
"purpose" text,
|
||||
"tax_year" integer NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "funders" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"ein" text NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"city" text,
|
||||
"state" text,
|
||||
"ntee_code" text,
|
||||
"total_assets" bigint,
|
||||
"application_info" jsonb,
|
||||
"latest_tax_year" integer,
|
||||
"latest_object_id" text,
|
||||
"created_at" timestamp with time zone DEFAULT now(),
|
||||
"updated_at" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "grants" ADD COLUMN "funder_ein" text;--> statement-breakpoint
|
||||
ALTER TABLE "funder_grants" ADD CONSTRAINT "funder_grants_funder_id_funders_id_fk" FOREIGN KEY ("funder_id") REFERENCES "public"."funders"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "idx_funder_grants_funder" ON "funder_grants" USING btree ("funder_id");--> statement-breakpoint
|
||||
CREATE INDEX "idx_funder_grants_funder_year" ON "funder_grants" USING btree ("funder_id","tax_year");--> statement-breakpoint
|
||||
CREATE INDEX "idx_funder_grants_recipient_state" ON "funder_grants" USING btree ("recipient_state");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "idx_funders_ein" ON "funders" USING btree ("ein");--> statement-breakpoint
|
||||
CREATE INDEX "idx_funders_state" ON "funders" USING btree ("state");--> statement-breakpoint
|
||||
CREATE INDEX "idx_grants_funder_ein" ON "grants" USING btree ("funder_ein");
|
||||
1460
packages/outreach-core/drizzle/server/meta/1784236406_snapshot.json
Normal file
1460
packages/outreach-core/drizzle/server/meta/1784236406_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,13 @@
|
||||
"when": 1784235098035,
|
||||
"tag": "1784235098_match-uniques",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "7",
|
||||
"when": 1784236406321,
|
||||
"tag": "1784236406_funder-precedent-index",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user