def sync_weibo(): # query entities needed to sync entities = Entity.objects.filter(sync_timestamp1__range=(datetime.datetime.now(), datetime.datetime.now()+datetime.timedelta(minutes=5)), status1=1) for entity in entities: weibo_message = None if entity.type == Entity.GAME: weibo_message = weibo_message_builder.build_game_message(Game.objects.get(id=entity.id)) logger.info('sync game %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.REDIER: weibo_message = weibo_message_builder.build_redier_message(Redier.objects.get(id=entity.id)) logger.info('sync redier %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.COLLECTION: weibo_message = weibo_message_builder.build_collection_message(Collection.objects.get(id=entity.id)) logger.info('sync collection %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.PROBLEM: weibo_message = weibo_message_builder.build_problem_message(Problem.objects.get(id=entity.id)) logger.info('sync problem %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.PLAYER: weibo_message = weibo_message_builder.build_player_message(Player.objects.get(id=entity.id)) logger.info('sync player %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.PUZZLE: weibo_message = weibo_message_builder.build_puzzle_message(Puzzle.objects.get(id=entity.id)) logger.info('sync puzzle %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.NEWS: weibo_message = weibo_message_builder.build_news_message(News.objects.get(id=entity.id)) logger.info('sync news %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.EVALUATION: weibo_message = weibo_message_builder.build_evaluation_message(Evaluation.objects.get(id=entity.id)) logger.info('sync evaluation %s to weibo' % weibo_message.entity_id) if weibo_message is not None: MessageSender.send_weibo(weibo_message) else: logger.info('nothing to sync to weibo')
def sync_weibo(): # query entities needed to sync entities = Entity.objects.filter( sync_timestamp1__range=(datetime.datetime.now(), datetime.datetime.now() + datetime.timedelta(minutes=5)), status1=1) for entity in entities: weibo_message = None if entity.type == Entity.GAME: weibo_message = weibo_message_builder.build_game_message( Game.objects.get(id=entity.id)) logger.info('sync game %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.REDIER: weibo_message = weibo_message_builder.build_redier_message( Redier.objects.get(id=entity.id)) logger.info('sync redier %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.COLLECTION: weibo_message = weibo_message_builder.build_collection_message( Collection.objects.get(id=entity.id)) logger.info('sync collection %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.PROBLEM: weibo_message = weibo_message_builder.build_problem_message( Problem.objects.get(id=entity.id)) logger.info('sync problem %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.PLAYER: weibo_message = weibo_message_builder.build_player_message( Player.objects.get(id=entity.id)) logger.info('sync player %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.PUZZLE: weibo_message = weibo_message_builder.build_puzzle_message( Puzzle.objects.get(id=entity.id)) logger.info('sync puzzle %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.NEWS: weibo_message = weibo_message_builder.build_news_message( News.objects.get(id=entity.id)) logger.info('sync news %s to weibo' % weibo_message.entity_id) elif entity.type == Entity.EVALUATION: weibo_message = weibo_message_builder.build_evaluation_message( Evaluation.objects.get(id=entity.id)) logger.info('sync evaluation %s to weibo' % weibo_message.entity_id) if weibo_message is not None: MessageSender.send_weibo(weibo_message) else: logger.info('nothing to sync to weibo')