Skip to content

Commit ebe6d25

Browse files
MaxGhenisclaude
andcommitted
Fix tests to use BatchSupabaseClient
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ff34a6d commit ebe6d25

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

scripts/load_pe_targets_batch.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ def _upsert_single(self, table: str, record: Dict, on_conflict: str):
137137
headers = {**self.headers, "Prefer": "return=representation"}
138138
self._request("POST", url, headers=headers, json=record)
139139

140+
def batch_upsert_strata(self, strata: List[Dict], return_mapping: bool = False) -> Any:
141+
"""Batch upsert strata with optional name->id mapping."""
142+
result = self.batch_upsert("strata", strata, "name,jurisdiction")
143+
if return_mapping:
144+
return {(r["name"], r["jurisdiction"]): r["id"] for r in result}
145+
return result
146+
147+
def batch_upsert_targets(self, targets: List[Dict], chunk_size: int = 500) -> List[Dict]:
148+
"""Batch upsert targets."""
149+
return self.batch_upsert("targets", targets, "source_id,stratum_id,variable,period",
150+
chunk_size=chunk_size)
151+
140152

141153
@dataclass
142154
class TargetCollector:

tests/test_supabase_batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import responses
1515
import json
1616

17-
# Import will fail until we implement the class
17+
# Import the batch client
1818
try:
19-
from scripts.load_pe_targets_to_supabase import SupabaseClient
19+
from scripts.load_pe_targets_batch import BatchSupabaseClient as SupabaseClient
2020
except ImportError:
2121
SupabaseClient = None
2222

0 commit comments

Comments
 (0)