From 0e81353ce09a775a23ef8eae68128369c1ca4738 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 4 May 2018 13:39:45 -0700 Subject: [PATCH] bots: Merged get_services_for_bots into its caller. This function is now only a few lines of simple code called in one place, and is better eliminated. --- zerver/lib/actions.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 48bfb63b94..59b5b65e6f 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -4715,17 +4715,12 @@ def get_service_dicts_for_bot(user_profile_id: str) -> List[Dict[str, Any]]: pass return service_dicts -def get_services_for_bots(bot_profile_ids: List[int]) -> Dict[int, List[Service]]: - services = Service.objects.filter(user_profile_id__in=bot_profile_ids) - services_by_uid = defaultdict(list) # type: Dict[int, List[Service]] - for service in services: - services_by_uid[service.user_profile.id].append(service) - return services_by_uid - def get_service_dicts_for_bots(bot_dicts: List[Dict[str, Any]], realm: Realm) -> Dict[int, List[Dict[str, Any]]]: bot_profile_ids = [bot_dict['id'] for bot_dict in bot_dicts] - bot_services_by_uid = get_services_for_bots(bot_profile_ids) + bot_services_by_uid = defaultdict(list) # type: Dict[int, List[Service]] + for service in Service.objects.filter(user_profile_id__in=bot_profile_ids): + bot_services_by_uid[service.user_profile.id].append(service) embedded_bot_ids = [bot_dict['id'] for bot_dict in bot_dicts if bot_dict['bot_type'] == UserProfile.EMBEDDED_BOT]