Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions opencontractserver/documents/services/relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def get_relationship_counts_by_document(
qs = qs.filter(corpus_id=corpus_id)

counts: defaultdict[int, int] = defaultdict(int)
for row in qs.values("source_document_id").annotate(c=Count("id")):
counts[row["source_document_id"]] += row["c"]
for source_row in qs.values("source_document_id").annotate(c=Count("id")):
counts[source_row["source_document_id"]] += source_row["c"]
# Exclude self-referential rows from the target-side aggregation so a
# relationship where source == target only contributes once. Without
# this guard, such a row would be counted both as a source and as a
Expand Down
13 changes: 11 additions & 2 deletions opencontractserver/shared/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,14 @@ class NullableJSONField(DbJSONField):

empty_values = [None, "", [], (), {}]

def formfield(self, **kwargs: Any) -> Any: # type: ignore[override]
return super().formfield(**{"form_class": UTF8JSONFormField, **kwargs})
def formfield(
self,
form_class: Optional[type[Any]] = UTF8JSONFormField,
choices_form_class: Optional[type[Any]] = None,
**kwargs: Any,
) -> Any:
return super().formfield(
form_class=form_class,
choices_form_class=choices_form_class,
**kwargs,
)
2 changes: 1 addition & 1 deletion requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ watchfiles==1.2.0 # https://github.com/samuelcolvin/watchfiles
# ------------------------------------------------------------------------------

mypy==2.3.0 # https://github.com/python/mypy
django-stubs==6.0.6 # https://github.com/typeddjango/django-stubs
django-stubs==6.0.7 # https://github.com/typeddjango/django-stubs
pytest==9.1.1 # https://github.com/pytest-dev/pytest
pytest-cov==7.1.0 # https://github.com/pytest-dev/pytest-cov
pytest-xdist==3.8.0 # https://github.com/pytest-dev/pytest-xdist (parallel test execution)
Expand Down