From: Christopher Allan Webber Date: Mon, 27 Jun 2011 21:56:41 +0000 (-0500) Subject: Adding our current indexes and removing the index that was in models.py X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b1db6f20dd3cdef9da9ad27513aeee2738c85262;p=mediagoblin.git Adding our current indexes and removing the index that was in models.py --- 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