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 CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ keywords:
- elasticsearch
- natural language processing
license: MIT
version: 5.30.0
date-released: '2026-04-09'
version: 5.30.1
date-released: '2026-05-19'
15 changes: 14 additions & 1 deletion backend/visualization/tests/test_visualization_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from visualization.query import MATCH_ALL
from visualization.views import TERM_FREQUENCY_SIZE_LIMIT
import pytest
import math
from rest_framework import status

@pytest.fixture()
Expand Down Expand Up @@ -86,13 +88,24 @@ def test_date_term_frequency(transactional_db, admin_client, date_term_frequency
post_response = admin_client.post('/api/visualization/date_term_frequency', date_term_frequency_body, content_type='application/json')
assert post_response.status_code == 400

def test_term_frequency_limit(transactional_db, admin_client, date_term_frequency_body, aggregate_term_frequency_body, index_small_mock_corpus, celery_worker):
def test_date_term_frequency_limit(transactional_db, admin_client, date_term_frequency_body, index_small_mock_corpus, celery_worker):
for bin in date_term_frequency_body['bins']:
bin['size'] = 1000000
post_response = admin_client.post('/api/visualization/date_term_frequency', date_term_frequency_body, content_type='application/json')
assert post_response.status_code == 400

for bin in date_term_frequency_body['bins']:
bin['size'] = math.ceil(TERM_FREQUENCY_SIZE_LIMIT / len(date_term_frequency_body['bins']))
post_response = admin_client.post('/api/visualization/date_term_frequency', date_term_frequency_body, content_type='application/json')
assert post_response.status_code == 200

def test_aggregate_term_frequency_limit(transactional_db, admin_client, aggregate_term_frequency_body, index_small_mock_corpus, celery_worker):
for bin in aggregate_term_frequency_body['bins']:
bin['size'] = 1000000
post_response = admin_client.post('/api/visualization/aggregate_term_frequency', aggregate_term_frequency_body, content_type='application/json')
assert post_response.status_code == 400

for bin in aggregate_term_frequency_body['bins']:
bin['size'] = math.ceil(TERM_FREQUENCY_SIZE_LIMIT / len(aggregate_term_frequency_body['bins']))
post_response = admin_client.post('/api/visualization/aggregate_term_frequency', aggregate_term_frequency_body, content_type='application/json')
assert post_response.status_code == 200
13 changes: 8 additions & 5 deletions backend/visualization/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
`10.000 + N(bins)`.
'''

def validate_term_frequency_size(bins):
max_size = TERM_FREQUENCY_SIZE_LIMIT + len(bins)
if sum(bin['size'] for bin in bins) > max_size:
raise ValidationError(detail='Maximum size exceeded')



class WordcloudView(APIView):
'''
Expand Down Expand Up @@ -121,8 +127,7 @@ def post(self, request, *args, **kwargs):
raise ParseError(
detail=f'key {key} is not present for all bins in request data')

if sum(bin['size'] for bin in bins) > TERM_FREQUENCY_SIZE_LIMIT:
raise ValidationError(detail='Maximum size exceeded')
validate_term_frequency_size(bins)

try:
group = tasks.timeline_term_frequency_tasks(
Expand Down Expand Up @@ -153,9 +158,7 @@ def post(self, request, *args, **kwargs):
raise ParseError(
detail=f'key {key} is not present for all bins in request data')

max_size = TERM_FREQUENCY_SIZE_LIMIT + len(bins)
if sum(bin['size'] for bin in bins) > max_size:
raise ValidationError(detail='Maximum size exceeded')
validate_term_frequency_size(bins)

try:
group = tasks.histogram_term_frequency_tasks(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "textcavator",
"version": "5.30.0",
"version": "5.30.1",
"license": "MIT",
"scripts": {
"postinstall": "yarn install-back && yarn install-front",
Expand Down
Loading