mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-13 07:29:39 +00:00
LiveSync: Add setting to disable category runs
This commit is contained in:
parent
5a9f9b7661
commit
5fac9e5d94
@ -22,7 +22,7 @@ from indico.util.decorators import classproperty
|
||||
from indico_livesync.forms import AgentForm
|
||||
from indico_livesync.initial import (apply_acl_entry_strategy, query_attachments, query_contributions, query_events,
|
||||
query_notes, query_subcontributions)
|
||||
from indico_livesync.models.queue import LiveSyncQueueEntry
|
||||
from indico_livesync.models.queue import EntryType, LiveSyncQueueEntry
|
||||
from indico_livesync.plugin import LiveSyncPlugin
|
||||
|
||||
|
||||
@ -97,11 +97,13 @@ class LiveSyncBackendBase:
|
||||
return True, None
|
||||
return False, 'initial export not performed'
|
||||
|
||||
def fetch_records(self, count=None):
|
||||
def fetch_records(self):
|
||||
query = (self.agent.queue
|
||||
.filter_by(processed=False)
|
||||
.order_by(LiveSyncQueueEntry.timestamp)
|
||||
.limit(count))
|
||||
.filter(~LiveSyncQueueEntry.processed)
|
||||
.order_by(LiveSyncQueueEntry.timestamp))
|
||||
if LiveSyncPlugin.settings.get('skip_category_changes'):
|
||||
LiveSyncPlugin.logger.warning('Category changes are currently being skipped')
|
||||
query = query.filter(LiveSyncQueueEntry.type != EntryType.category)
|
||||
return query.all()
|
||||
|
||||
def update_last_run(self):
|
||||
|
||||
@ -35,6 +35,11 @@ class SettingsForm(IndicoForm):
|
||||
"subcategories are excluded."))
|
||||
disable_queue_runs = BooleanField(_('Disable queue runs'), widget=SwitchWidget(),
|
||||
description=_('Disable all scheduled queue runs.'))
|
||||
skip_category_changes = BooleanField(_('Skip category changes'), widget=SwitchWidget(),
|
||||
description=_('Skip category changes when processing the queue. This can be '
|
||||
'useful in large instances when there are significant changes '
|
||||
'to large categories in order to avoid processing those '
|
||||
'immediately.'))
|
||||
|
||||
|
||||
class LiveSyncPlugin(IndicoPlugin):
|
||||
@ -47,7 +52,8 @@ class LiveSyncPlugin(IndicoPlugin):
|
||||
settings_form = SettingsForm
|
||||
default_settings = {'excluded_categories': [],
|
||||
'queue_entry_ttl': 0,
|
||||
'disable_queue_runs': False}
|
||||
'disable_queue_runs': False,
|
||||
'skip_category_changes': False}
|
||||
category = PluginCategory.synchronization
|
||||
|
||||
def init(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user