aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-12-08 18:05:26 +0100
committerMilo Casagrande <milo.casagrande@linaro.org>2014-12-08 18:05:26 +0100
commit02c6a69fc9b64bfd1ce8151a7d07bd2709d80001 (patch)
tree6ee9bb5434ca0b32af836678cf4c1e9e93f3fb93
parentc9b0ae0be27161450dd2b455827013b2ab477a25 (diff)
Add indexes for lab collection.2014.12.3
Change-Id: I0b96f2a6d7c02b10179b5fb1c47efd07a7e6e27f
-rw-r--r--app/handlers/dbindexes.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/app/handlers/dbindexes.py b/app/handlers/dbindexes.py
index 1beb23c..547fc4e 100644
--- a/app/handlers/dbindexes.py
+++ b/app/handlers/dbindexes.py
@@ -40,6 +40,7 @@ def ensure_indexes(client, db_options):
_ensure_boot_indexes(database)
_ensure_defconfig_indexes(database)
_ensure_token_indexes(database)
+ _ensure_lab_indexes(database)
def _ensure_job_indexes(database):
@@ -95,10 +96,6 @@ def _ensure_defconfig_indexes(database):
collection = database[models.DEFCONFIG_COLLECTION]
collection.ensure_index(
- [(models.CREATED_KEY, pymongo.DESCENDING)], background=True)
- collection.ensure_index(
- [(models.STATUS_KEY, pymongo.ASCENDING)], background=True)
- collection.ensure_index(
[
(models.CREATED_KEY, pymongo.DESCENDING),
(models.ID_KEY, pymongo.DESCENDING),
@@ -134,3 +131,27 @@ def _ensure_token_indexes(database):
collection.ensure_index(
[(models.TOKEN_KEY, pymongo.DESCENDING)], background=True
)
+ collection.ensure_index(
+ [
+ (models.ID_KEY, pymongo.DESCENDING),
+ (models.TOKEN_KEY, pymongo.ASCENDING)
+ ],
+ background=True
+ )
+
+
+def _ensure_lab_indexes(database):
+ """Ensure indexes exists for the 'lab' collection.
+
+ :param database: The database connection.
+ """
+ collection = database[models.LAB_COLLECTION]
+
+ collection.ensure_index(
+ [
+ (models.ID_KEY, pymongo.DESCENDING),
+ (models.NAME_KEY, pymongo.ASCENDING),
+ (models.TOKEN_KEY, pymongo.ASCENDING)
+ ],
+ background=True
+ )