From 1e5f830fe76b96731d7a95f2baf099a3334bbe3a Mon Sep 17 00:00:00 2001 From: gordon chung Date: Mon, 2 Mar 2015 16:41:02 -0500 Subject: [PATCH] use mongodb distinct we should use distinct capability mongo provides and not try to do it ourselves. Change-Id: I8a77308475e3e0b12430fcff0496caa1905eef10 Closes-Bug: #1427393 --- ceilometer/event/storage/pymongo_base.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ceilometer/event/storage/pymongo_base.py b/ceilometer/event/storage/pymongo_base.py index 461db6b13..1efc7215a 100644 --- a/ceilometer/event/storage/pymongo_base.py +++ b/ceilometer/event/storage/pymongo_base.py @@ -98,14 +98,7 @@ class Connection(base.Connection): def get_event_types(self): """Return all event types as an iter of strings.""" - event_types = set() - events = self.db.event.find() - - for event in events: - event_type = event['event_type'] - if event_type not in event_types: - event_types.add(event_type) - yield event_type + return self.db.event.distinct('event_type') def get_trait_types(self, event_type): """Return a dictionary containing the name and data type of the trait.