From b1db6f20dd3cdef9da9ad27513aeee2738c85262 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 27 Jun 2011 16:56:41 -0500 Subject: [PATCH] Adding our current indexes and removing the index that was in models.py --- mediagoblin/db/indexes.py | 18 ++++++++++++------ mediagoblin/db/models.py | 5 ----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mediagoblin/db/indexes.py b/mediagoblin/db/indexes.py index 85d43471..bd97f9f2 100644 --- a/mediagoblin/db/indexes.py +++ b/mediagoblin/db/indexes.py @@ -37,6 +37,8 @@ REQUIRED READING: - http://www.mongodb.org/display/DOCS/Indexes - http://www.mongodb.org/display/DOCS/Indexing+Advice+and+FAQ + + """ from pymongo import ASCENDING, DESCENDING @@ -51,7 +53,7 @@ ACTIVE_INDEXES = {} # ------------------ MEDIAENTRY_INDEXES = { - 'mediaentry_uploader_slug_unique': { + 'uploader_slug_unique': { # Matching an object to an uploader + slug. # MediaEntries are unique on these two combined, eg: # /u/${myuser}/m/${myslugname}/ @@ -59,12 +61,12 @@ MEDIAENTRY_INDEXES = { ('slug', ASCENDING)], 'unique': True}, - 'mediaentry_created': { + 'created': { # A global index for all media entries created, in descending # order. This is used for the site's frontpage. 'index': [('created', DESCENDING)]}, - 'mediaentry_uploader_created': { + 'uploader_created': { # Indexing on uploaders and when media entries are created. # Used for showing a user gallery, etc. 'index': [('uploader', ASCENDING), @@ -78,15 +80,15 @@ ACTIVE_INDEXES['media_entries'] = MEDIAENTRY_INDEXES # ------------ USER_INDEXES = { - 'user_username_unique': { + 'username_unique': { # Index usernames, and make sure they're unique. # ... I guess we might need to adjust this once we're federated :) 'index': 'username', 'unique': True}, - 'user_created': { + 'created': { # All most recently created users 'index': 'created'}} - + ACTIVE_INDEXES['users'] = USER_INDEXES @@ -95,4 +97,8 @@ ACTIVE_INDEXES['users'] = USER_INDEXES # Deprecated indexes #################### +# @@: Do we really need to keep the index form if we're removing by +# key name? I guess it's helpful to keep the record... + + DEPRECATED_INDEXES = {} diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 600b79ff..8d06ae49 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -108,11 +108,6 @@ class MediaEntry(Document): migration_handler = migrations.MediaEntryMigration - indexes = [ - # Referene uniqueness of slugs by uploader - {'fields': ['uploader', 'slug'], - 'unique': True}] - def main_mediafile(self): pass -- 2.25.1