Commit d9e2178
committed
Address PR #1376 follow-up: lazy subqueries, top-level import, test gap
Follow-up to issue #1377:
- Move ``StructuralAnnotationSet`` to the existing top-level
``opencontractserver.annotations.models`` import. ``Annotation`` was
already imported at module scope from the same module, so the inline
imports inside ``_build_base_queryset`` ("avoid circular imports") had
no rationale.
- Convert ``active_doc_ids`` and ``visible_corpus_doc_ids`` from
Python-materialised lists to fully lazy querysets so the SQL planner
receives ``IN (SELECT ...)`` subqueries rather than
``IN (val, val, ...)`` literals — important for corpora with tens of
thousands of documents. The deletion-aware empty-corpus short-circuit
now uses ``.exists()`` instead of list truthiness.
- Add ``.distinct()`` to ``visible_corpus_set_ids`` and
``active_struct_set_ids`` for consistency with
``visible_corpus_doc_ids`` and to avoid duplicate IDs when a structural
set is shared across multiple documents in the corpus.
- Drop stale ``(line 211)`` line-number anchor from the corpus-only
branch comment.
- Add ``test_deletion_aware_path_excludes_deleted_document_structural``
to close the previously uncovered branch where
``check_corpus_deletion=True`` AND a document's only ``DocumentPath``
has ``is_deleted=True`` — the structural annotation must be excluded.1 parent c7f6732 commit d9e2178
2 files changed
Lines changed: 71 additions & 30 deletions
File tree
- opencontractserver
- llms/vector_stores
- tests
Lines changed: 37 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
293 | | - | |
294 | 292 | | |
295 | 293 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
302 | 301 | | |
303 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
304 | 306 | | |
305 | | - | |
| 307 | + | |
306 | 308 | | |
307 | 309 | | |
308 | 310 | | |
| |||
311 | 313 | | |
312 | 314 | | |
313 | 315 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
318 | 324 | | |
319 | 325 | | |
320 | | - | |
321 | 326 | | |
322 | 327 | | |
323 | 328 | | |
| |||
396 | 401 | | |
397 | 402 | | |
398 | 403 | | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
409 | 417 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
414 | 421 | | |
415 | 422 | | |
416 | 423 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
263 | 297 | | |
264 | 298 | | |
265 | 299 | | |
| |||
0 commit comments