Ejemplo n.º 1
0
    def __init__(self, collection='stamps'):
        AMongoCollectionView.__init__(self, collection=collection, primary_key='stamp_id', obj=Stamp, overflow=True)
        AStampDB.__init__(self)
        
        self._collection.ensure_index([('timestamp.modified', pymongo.ASCENDING)])
        self._collection.ensure_index([('timestamp.created', pymongo.DESCENDING)])
        self._collection.ensure_index([('timestamp.stamped', pymongo.ASCENDING)])
        self._collection.ensure_index([('user.user_id', pymongo.ASCENDING), ('entity.entity_id', pymongo.ASCENDING)])
        self._collection.ensure_index([('user.user_id', pymongo.ASCENDING), ('stats.stamp_num', pymongo.ASCENDING)])
        self._collection.ensure_index([('entity.entity_id', pymongo.ASCENDING), ('credits.user.user_id', pymongo.ASCENDING)])
        self._collection.ensure_index([('credits.user.user_id', pymongo.ASCENDING)])
        
        # Indices for _getTimeSlice within AMongoCollectionView
        self._collection.ensure_index([('_id', pymongo.ASCENDING), ('entity.types', pymongo.ASCENDING), ('timestamp.stamped', pymongo.DESCENDING)])
        self._collection.ensure_index([('_id', pymongo.ASCENDING), ('timestamp.stamped', pymongo.DESCENDING)])
        self._collection.ensure_index([('entity.types', pymongo.ASCENDING), ('timestamp.stamped', pymongo.DESCENDING)])

        # Indices for _getSearchSlice
        self._collection.ensure_index([ ('_id', pymongo.ASCENDING), 
                                        ('entity.types', pymongo.ASCENDING), 
                                        ('search_blurb', pymongo.ASCENDING), 
                                        ('entity.coordinates.lng', pymongo.ASCENDING), 
                                        ('entity.coordinates.lat', pymongo.ASCENDING), 
                                        ('timestamp.stamped', pymongo.DESCENDING) ])
        
        self._collection.ensure_index([ ('_id', pymongo.ASCENDING), 
                                        ('entity.types', pymongo.ASCENDING), 
                                        ('entity.coordinates.lng', pymongo.ASCENDING), 
                                        ('entity.coordinates.lat', pymongo.ASCENDING), 
                                        ('timestamp.stamped', pymongo.DESCENDING) ])

        self._collection.ensure_index([ ('entity.types', pymongo.ASCENDING), 
                                        ('entity.coordinates.lng', pymongo.ASCENDING), 
                                        ('entity.coordinates.lat', pymongo.ASCENDING), 
                                        ('timestamp.stamped', pymongo.DESCENDING) ])
Ejemplo n.º 2
0
    def _convertToMongo(self, stamp):
        document = AMongoCollectionView._convertToMongo(self, stamp)

        searchBlurb = getSimplifiedTitle(stamp.entity.title)
        for content in stamp.contents:
            if content.blurb is not None:
                searchBlurb = "%s %s" % (searchBlurb, getSimplifiedTitle(content.blurb))
        
        document['search_blurb'] = searchBlurb
        return document
Ejemplo n.º 3
0
    def __init__(self, collection="favorites"):
        AMongoCollectionView.__init__(self, collection=collection, primary_key="todo_id", obj=RawTodo)
        ATodoDB.__init__(self)

        self._collection.ensure_index(
            [("entity.entity_id", pymongo.ASCENDING), ("user_id", pymongo.ASCENDING), ("_id", pymongo.DESCENDING)]
        )

        self._collection.ensure_index([("user_id", pymongo.ASCENDING), ("timestamp.created", pymongo.DESCENDING)])

        # Indices for _getTimeSlice within AMongoCollectionView
        self._collection.ensure_index(
            [
                ("user_id", pymongo.ASCENDING),
                ("entity.types", pymongo.ASCENDING),
                ("timestamp.stamped", pymongo.DESCENDING),
            ]
        )
        self._collection.ensure_index([("user_id", pymongo.ASCENDING), ("timestamp.stamped", pymongo.DESCENDING)])
        self._collection.ensure_index([("entity.types", pymongo.ASCENDING), ("timestamp.stamped", pymongo.DESCENDING)])
        self._collection.ensure_index([("source_stamp_ids", pymongo.ASCENDING)])
        self._collection.ensure_index([("stamp.stamp_id", pymongo.ASCENDING)])