1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011 Free Software Foundation, Inc
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 Indexes for the local database.
20 Indexes are recorded in the following format:
24 'identifier': { # key identifier used for possibly deprecating later
25 'index': [index_foo_goes_here]}}
27 ... and anything else being parameters to the create_index function
28 (including unique=True, etc)
30 Current indexes must be registered in ACTIVE_INDEXES... deprecated
31 indexes should be marked in DEPRECATED_INDEXES.
33 Remember, ordering of compound indexes MATTERS. Read below for more.
36 - http://kylebanker.com/blog/2010/09/21/the-joy-of-mongodb-indexes/
38 - http://www.mongodb.org/display/DOCS/Indexes
39 - http://www.mongodb.org/display/DOCS/Indexing+Advice+and+FAQ
44 from pymongo
import ASCENDING
, DESCENDING
55 MEDIAENTRY_INDEXES
= {
56 'uploader_slug_unique': {
57 # Matching an object to an uploader + slug.
58 # MediaEntries are unique on these two combined, eg:
59 # /u/${myuser}/m/${myslugname}/
60 'index': [('uploader', ASCENDING
),
65 # A global index for all media entries created, in descending
66 # order. This is used for the site's frontpage.
67 'index': [('created', DESCENDING
)]},
70 # Indexing on uploaders and when media entries are created.
71 # Used for showing a user gallery, etc.
72 'index': [('uploader', ASCENDING
),
73 ('created', DESCENDING
)]}}
76 ACTIVE_INDEXES
['media_entries'] = MEDIAENTRY_INDEXES
84 # Index usernames, and make sure they're unique.
85 # ... I guess we might need to adjust this once we're federated :)
89 # All most recently created users
93 ACTIVE_INDEXES
['users'] = USER_INDEXES
100 # @@: Do we really need to keep the index form if we're removing by
101 # key name? I guess it's helpful to keep the record...
104 DEPRECATED_INDEXES
= {}