Skip to content

Commit df62135

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 eda719f commit df62135

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
@@ -263,7 +263,7 @@ def set_leaf_nodes_invisible(
263263
if clear_admin_imported:
264264
values_dict["admin_imported"] = False
265265

266-
# Each batch commits on its own, as it did under SQLAlchemy's autocommit.
266+
# Deliberately not wrapped in a transaction: each batch commits on its own.
267267
while min_boundary < max_rght:
268268
_batch_queryset(
269269
channel_id,
@@ -329,7 +329,7 @@ def set_leaf_node_availability_from_local_file_availability(
329329
output_field=BooleanField(),
330330
)
331331

332-
# Each batch commits on its own, as it did under SQLAlchemy's autocommit.
332+
# Deliberately not wrapped in a transaction: each batch commits on its own.
333333
while min_boundary < max_rght:
334334
_batch_queryset(
335335
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)