Skip to content

Instantly share code, notes, and snippets.

@esimonetti
Last active November 24, 2017 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esimonetti/29dfb1d5b4e138095cb6cba8bee5ef37 to your computer and use it in GitHub Desktop.
Save esimonetti/29dfb1d5b4e138095cb6cba8bee5ef37 to your computer and use it in GitHub Desktop.
Sample customised notifications view to increase Notifications polling and separate delays for Notifications from Meetings and Calls reminders
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-24 tested on Sugar 7.9.2.0
// Sample customised notifications view to increase Notifications polling and separate delays for Notifications from Meetings and Calls reminders
//
// IMPORTANT: Lowering the delay values through the configuration options will increase the frequency of the amount of requests completed to the server, for every user's open browser tab. You need to consider the server load implications and sizing requirements.
//
// file: custom/clients/base/views/notifications/notifications.js
({
extendsFrom: 'NotificationsView',
_lastReminderRun: 0,
_customDelayReminderRun: 0,
initialize: function(options) {
this._super('initialize', [options]);
},
_pullReminders: function(bulkApiId) {
var now = Math.floor(Date.now() / 1000);
if(_.isEmpty(this.meta.customStopReminders)) {
// set the configured interval on first run
if(this._customDelayReminderRun === 0) {
this._customDelayReminderRun = this.meta.customDelayReminderRun || 120;
}
// run actual pull only when the customDelayReminderRun has elapsed
if(this._lastReminderRun < (now - this._customDelayReminderRun)) {
this._lastReminderRun = now;
return this._super('_pullReminders', [bulkApiId]);
}
}
}
})
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-24 tested on Sugar 7.9.2.0
// Sample config for customised notifications view to increase Notifications polling and separate delays for Notifications from Meetings and Calls reminders
//
// IMPORTANT: Lowering the delay values will increase the frequency of the amount of requests completed to the server, for every user's open browser tab. You need to consider the server load implications and sizing requirements.
//
// file: custom/clients/base/views/notifications/notifications.php
$viewdefs['base']['view']['notifications']['delay'] = 2; // in minutes. drives the frequency of API requests
$viewdefs['base']['view']['notifications']['customDelayReminderRun'] = 600; // in seconds. This is a timespan delay for Meetings and Calls reminders, based on the main frequency of execution based on the original delay option
$viewdefs['base']['view']['notifications']['customStopReminders'] = false; // boolean. It prevents Meetings and Calls reminders retrieval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment