Skip to content

Commit 849c999

Browse files
rtibblesbotclaude
andcommitted
Delete the dead checksum filter from sqlalchemybridge
annotation.py and importability_annotation.py were its only callers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent c6230bb commit 849c999

2 files changed

Lines changed: 2 additions & 38 deletions

File tree

kolibri/core/content/utils/annotation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def set_leaf_nodes_invisible(
265265
if clear_admin_imported:
266266
values_dict["admin_imported"] = False
267267

268-
# Each batch commits on its own, as it did under SQLAlchemy's autocommit.
268+
# Deliberately not wrapped in a transaction: each batch commits on its own.
269269
while min_boundary < max_rght:
270270
_batch_queryset(
271271
channel_id,
@@ -331,7 +331,7 @@ def set_leaf_node_availability_from_local_file_availability(
331331
output_field=BooleanField(),
332332
)
333333

334-
# Each batch commits on its own, as it did under SQLAlchemy's autocommit.
334+
# Deliberately not wrapped in a transaction: each batch commits on its own.
335335
while min_boundary < max_rght:
336336
_batch_queryset(
337337
channel_id,

kolibri/core/content/utils/sqlalchemybridge.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import importlib
22
import logging
33
import os
4-
import re
54
from uuid import UUID
65

76
from django.apps import apps
@@ -398,41 +397,6 @@ def _by_uuids(field, ids, validate, include, vendor=None):
398397
return UnaryExpression(field, modifier=operators.custom_op(empty_query))
399398

400399

401-
checksum_re = re.compile("^[0-9a-f]{32}$")
402-
403-
404-
def _validate_checksums(checksums):
405-
for checksum in checksums:
406-
if not checksum_re.match(checksum):
407-
raise ValueError("Invalid checksum: {}".format(checksum))
408-
409-
410-
def filter_by_checksums(field, checksums):
411-
query = "IN ("
412-
# trick to workaround postgresql, it does not allow returning ():
413-
empty_query = "IS NULL"
414-
if checksums:
415-
if len(checksums) > 10000:
416-
logger.warning(
417-
"""
418-
More than 10000 UUIDs passed to filter by checksums method,
419-
these should be batched into separate querysets to avoid SQL Query too large errors in SQLite
420-
"""
421-
)
422-
try:
423-
_validate_checksums(checksums)
424-
checksums_list = ["'{}'".format(identifier) for identifier in checksums]
425-
return UnaryExpression(
426-
field,
427-
modifier=operators.custom_op(query + ",".join(checksums_list) + ")"),
428-
)
429-
except ValueError:
430-
# the value is not a valid hex code for a checksum, so fall through to the
431-
# empty case and don't return any results
432-
pass
433-
return UnaryExpression(field, modifier=operators.custom_op(empty_query))
434-
435-
436400
def coerce_key(key):
437401
if isinstance(key, UUID):
438402
return key.hex

0 commit comments

Comments
 (0)