Skip to content

Commit

Permalink
Update settings in batches. Beginning to run out of memory with a gia…
Browse files Browse the repository at this point in the history
…nt JSON uniblob
  • Loading branch information
sidoh committed Sep 22, 2019
1 parent 96e54bc commit f692777
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions web/src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,27 @@ $(function() {

$('#settings').prepend(settings);

function saveSettings(settingsEntries) {
var entries = settingsEntries.slice(0)

function saveBatch() {
if (entries.length > 0) {
var batch = Object.fromEntries(entries.splice(0, 30))
$.ajax(
"/settings",
{
method: "PUT",
contentType: "application/json",
data: JSON.stringify(batch)
}
)
.done(saveBatch)
}
}

saveBatch()
}

$('#settings').submit(function(e) {
e.preventDefault();

Expand Down Expand Up @@ -1262,15 +1283,7 @@ $(function() {
// Make sure we're submitting a value for group_state_fields (will be empty
// if no values were selected).
obj = $.extend({group_state_fields: []}, obj);

$.ajax(
"/settings",
{
method: 'put',
contentType: 'application/json',
data: JSON.stringify(obj)
}
);
saveSettings(Object.entries(obj))
}

$('#settings-modal').modal('hide');
Expand Down

0 comments on commit f692777

Please sign in to comment.