Skip to content

Commit

Permalink
Merge pull request #594 from knabar/fix-small-table-download
Browse files Browse the repository at this point in the history
Add minimum batch size to avoid infinite loop due to zero batch size
  • Loading branch information
knabar authored Nov 19, 2024
2 parents 213bb61 + 6bba7f7 commit 2755194
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ <h2>{{ data.name }}</h2>
enableDownloadButtons(false);
const rowCount = filter ? parseInt("{{ meta.totalCount }}") : parseInt("{{ meta.rowCount }}");
const tableName = "{{ data.name }}.csv";
// Use 10 batches, or max 3000 rows per batch
// Use 10 batches, or max 3000 rows per batch, with a minimum of 10
const MAX_BATCH_ROWS = 3000;
const MIN_BATCH_ROWS = 10;
const MAX_FAILED_CALLS = 5;
const batchSize = Math.min(parseInt(rowCount/10), MAX_BATCH_ROWS);
const batchSize = Math.max(Math.min(parseInt(rowCount/10), MAX_BATCH_ROWS), MIN_BATCH_ROWS);

// load csv in batches...
const csvUrl = "{% url 'omero_table' data.id 'csv' %}";
Expand Down

0 comments on commit 2755194

Please sign in to comment.