Only update timescale pref in db on change

The /Schedule/set-time-scale/format/json was being hit every time a new calendar page was displayed. The isn't good for performance reasons and also makes race conditions like #210 much more likely.

With this change the preference is only updated on the server when the GUI state changes because the user clicked on one of the "Day", "Week", or "Month" buttons.

This does not fix the locking issue completely, but it should help because the cc_prefs time-scale row in the database will get locked much less often. After applying this I wasn't able to reproduce #210 any more on an install with an extensive schedule.
This commit is contained in:
Lucas Bickel 2017-06-03 23:05:18 +02:00
parent e7d1359117
commit b1f840ee0f
1 changed files with 6 additions and 3 deletions

View File

@ -177,9 +177,12 @@ function viewDisplay( view ) {
}
}
//save view name to db
var url = baseUrl+'Schedule/set-time-scale/format/json';
$.post(url, {timeScale: view.name});
//save view name to db if it was changed
if (calendarPref.timeScale !== view.name) {
var url = baseUrl+'Schedule/set-time-scale/format/json';
$.post(url, {timeScale: view.name});
calendarPref.timeScale = view.name;
}
}
function eventRender(event, element, view) {