diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-22 15:10:13 +0200 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-22 15:10:13 +0200 |
commit | 6fd20a6d6f7723a70a0b4f75c8b26c73a3545a34 (patch) | |
tree | 371eb1a8c83178abcaba03e10cfc96f639beaa2b | |
parent | 2dd462109071c182087ea72b6903d7899a6eaff8 (diff) |
#117 getting partial results when loading mails
-rw-r--r-- | service/pixelated/config/app_factory.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/service/pixelated/config/app_factory.py b/service/pixelated/config/app_factory.py index 9ea00bb9..4aa789e0 100644 --- a/service/pixelated/config/app_factory.py +++ b/service/pixelated/config/app_factory.py @@ -30,12 +30,19 @@ from leap.common.events import ( register, events_pb2 as proto ) -from pixelated.controllers import sync_info_controller -def init_index_and_delete_duplicate_inboxes(querier, search_engine, mail_service): +def init_index_and_remove_dupes(querier, search_engine, mail_service): def wrapper(*args, **kwargs): - querier.remove_inbox_duplicates() + querier.remove_duplicates() + search_engine.index_mails(mail_service.all_mails(), callback=querier.mark_all_as_not_recent) + + return wrapper + + +def update_info_sync_and_index_partial(sync_info_controller, search_engine, mail_service): + def wrapper(soledad_sync_data): + sync_info_controller.set_sync_info(soledad_sync_data) search_engine.index_mails(mail_service.all_mails()) return wrapper @@ -90,13 +97,18 @@ def create_app(debug_enabled, app): tags_controller = TagsController(search_engine=search_engine) sync_info_controller = SyncInfoController() - register(signal=proto.SOLEDAD_SYNC_RECEIVE_STATUS, callback=sync_info_controller.set_sync_info) + + register(signal=proto.SOLEDAD_SYNC_RECEIVE_STATUS, + callback=update_info_sync_and_index_partial(sync_info_controller=sync_info_controller, + search_engine=search_engine, + mail_service=mail_service)) register(signal=proto.SOLEDAD_DONE_DATA_SYNC, - callback=init_index_and_delete_duplicate_inboxes(querier=soledad_querier, + callback=init_index_and_remove_dupes(querier=soledad_querier, search_engine=search_engine, mail_service=mail_service)) - _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller, sync_info_controller) + _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller, + sync_info_controller) app.run(host=app.config['HOST'], debug=debug_enabled, port=app.config['PORT'], use_reloader=False) |