# HG changeset patch # User neko259 # Date 2018-08-05 05:32:43 # Node ID b378f45d08bc182c6a8d9af6dc21b0cd51193ece # Parent f62cdfb1f90dcd3df7c83d40bed0886b303b29ce Changed sync processor output a bit diff --git a/boards/management/commands/sync_with_server.py b/boards/management/commands/sync_with_server.py --- a/boards/management/commands/sync_with_server.py +++ b/boards/management/commands/sync_with_server.py @@ -89,26 +89,7 @@ class Command(BaseCommand): models = root.findall('models')[0] for model in models: - tag_id = model.find(TAG_ID) - global_id, exists = GlobalId.from_xml_element(tag_id) - - from_this_board = self._is_from_this_board(global_id) - - if from_this_board: - # If the post originates from this board, no need to process - # it again, nobody else could modify it - logger.debug('* Processed (-) post {}'.format(global_id)) - else: - tag_update_time = model.find(TAG_UPDATE_TIME) - if tag_update_time: - update_time = tag_update_time.text - else: - update_time = None - if not exists or update_time is None or global_id.post.last_edit_time < parse_datetime(update_time): - logger.debug('Processed (+) post {}'.format(global_id)) - ids_to_sync.append(global_id) - else: - logger.debug('* Processed (-) post {}'.format(global_id)) + self.add_to_sync_list(ids_to_sync, logger, model) logger.info('Starting sync...') if len(ids_to_sync) > 0: @@ -128,6 +109,27 @@ class Command(BaseCommand): else: raise Exception('Invalid response status') + def add_to_sync_list(self, ids_to_sync, logger, model): + tag_id = model.find(TAG_ID) + global_id, exists = GlobalId.from_xml_element(tag_id) + from_this_board = self._is_from_this_board(global_id) + if from_this_board: + # If the post originates from this board, no need to process + # it again, nobody else could modify it + logger.debug('NO SYNC Processed post {}'.format(global_id)) + else: + tag_update_time = model.find(TAG_UPDATE_TIME) + if tag_update_time: + update_time = tag_update_time.text + else: + update_time = None + if not exists or update_time is None or global_id.post.last_edit_time < parse_datetime( + update_time): + logger.debug('SYNC Processed post {}'.format(global_id)) + ids_to_sync.append(global_id) + else: + logger.debug('NO SYNC Processed post {}'.format(global_id)) + def _is_from_this_board(self, global_id): from_this_board = KeyPair.objects.filter( key_type=global_id.key_type,