Skip to content

Commit c2faacf

Browse files
sanghoonioclaude
andcommitted
Use JSONB for distributions columns, add BedBatchResult model
- Change distributions (bed_stats) and bedset_stats (bedsets) columns from JSON to JSONB for native operator support in aggregation queries - Remove ::jsonb casts from aggregation SQL (no longer needed) - Add BedBatchResult model with BedMetadataAll results so batch endpoint includes stats in serialized response - get_batch returns BedBatchResult instead of BedListResult Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d57b578 commit c2faacf

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

bbconf/db_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
event,
1515
select,
1616
)
17-
from sqlalchemy.dialects.postgresql import ARRAY, JSON
17+
from sqlalchemy.dialects.postgresql import ARRAY, JSON, JSONB
1818
from sqlalchemy.engine import URL, Engine, create_engine
1919
from sqlalchemy.event import listens_for
2020
from sqlalchemy.exc import IntegrityError, ProgrammingError
@@ -256,7 +256,7 @@ class BedStats(Base):
256256
median_neighbor_distance: Mapped[Optional[float]]
257257

258258
distributions: Mapped[Optional[dict]] = mapped_column(
259-
JSON,
259+
JSONB,
260260
nullable=True,
261261
comment="Full distribution arrays from gtars genomicdist (JSONB)",
262262
)
@@ -344,7 +344,7 @@ class BedSets(Base):
344344
JSON, comment="Median values of the bedset"
345345
)
346346
bedset_stats: Mapped[Optional[dict]] = mapped_column(
347-
JSON,
347+
JSONB,
348348
nullable=True,
349349
comment="Pre-aggregated distribution statistics from gtars (JSONB)",
350350
)

bbconf/models/bed_models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ class BedListResult(BaseModel):
210210
results: list[BedMetadataBasic]
211211

212212

213+
class BedBatchResult(BaseModel):
214+
count: int
215+
limit: int
216+
offset: int
217+
results: list[BedMetadataAll]
218+
219+
213220
class QdrantSearchResult(BaseModel):
214221
id: str
215222
payload: dict = None

bbconf/modules/bedfiles.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def get_batch(
244244
identifiers: list,
245245
full: bool = False,
246246
distributions: bool = False,
247-
) -> "BedListResult":
247+
) -> "BedBatchResult":
248248
"""
249249
Get multiple bed file records by identifiers in a single DB round-trip.
250250
@@ -253,7 +253,7 @@ def get_batch(
253253
:param distributions: if True, include distribution arrays in stats
254254
:return: BedListResult with matching records
255255
"""
256-
from bbconf.models.bed_models import BedListResult, BedMetadataAll
256+
from bbconf.models.bed_models import BedBatchResult, BedMetadataAll
257257

258258
statement = select(Bed).where(Bed.id.in_(identifiers))
259259

@@ -296,7 +296,7 @@ def get_batch(
296296
)
297297
)
298298

299-
return BedListResult(
299+
return BedBatchResult(
300300
count=len(results),
301301
limit=len(identifiers),
302302
offset=0,

0 commit comments

Comments
 (0)