|
a/Allura/allura/command/show_models.py |
|
b/Allura/allura/command/show_models.py |
|
... |
|
... |
109 |
parser = base.Command.standard_parser(verbose=True)
|
109 |
parser = base.Command.standard_parser(verbose=True)
|
110 |
|
110 |
|
111 |
def command(self):
|
111 |
def command(self):
|
112 |
from allura import model as M
|
112 |
from allura import model as M
|
113 |
self.basic_setup()
|
113 |
self.basic_setup()
|
114 |
# Collect indexes by collection name
|
114 |
main_indexes = defaultdict(lambda: defaultdict(list)) # by db, then collection name
|
115 |
main_indexes = defaultdict(list)
|
|
|
116 |
project_indexes = defaultdict(list)
|
115 |
project_indexes = defaultdict(list) # by collection name
|
117 |
base.log.info('Collecting indexes...')
|
116 |
base.log.info('Collecting indexes...')
|
118 |
for m in Mapper.all_mappers():
|
117 |
for m in Mapper.all_mappers():
|
119 |
mgr = m.collection.m
|
118 |
mgr = m.collection.m
|
120 |
cname = mgr.collection_name
|
119 |
cname = mgr.collection_name
|
121 |
cls = m.mapped_class
|
120 |
cls = m.mapped_class
|
122 |
if cname is None:
|
121 |
if cname is None:
|
123 |
base.log.info('... skipping abstract class %s', cls)
|
122 |
base.log.info('... skipping abstract class %s', cls)
|
124 |
continue
|
123 |
continue
|
125 |
base.log.info('... for class %s', cls)
|
124 |
base.log.info('... for class %s', cls)
|
126 |
if session(cls) in (
|
125 |
if session(cls) in (
|
127 |
M.main_orm_session, M.repository_orm_session):
|
126 |
M.main_orm_session, M.repository_orm_session, M.task_orm_session):
|
128 |
idx = main_indexes[cname]
|
127 |
idx = main_indexes[session(cls)][cname]
|
129 |
else:
|
128 |
else:
|
130 |
idx = project_indexes[cname]
|
129 |
idx = project_indexes[cname]
|
131 |
idx.extend(mgr.indexes)
|
130 |
idx.extend(mgr.indexes)
|
132 |
base.log.info('Updating indexes for main DB')
|
131 |
base.log.info('Updating indexes for main DB')
|
133 |
db = M.main_doc_session.db
|
132 |
for odm_session, db_indexes in main_indexes.iteritems():
|
|
|
133 |
db = odm_session.impl.db
|
134 |
for name, indexes in main_indexes.iteritems():
|
134 |
for name, indexes in db_indexes.iteritems():
|
135 |
self._update_indexes(db[name], indexes)
|
135 |
self._update_indexes(db[name], indexes)
|
136 |
base.log.info('Updating indexes for project DBs')
|
136 |
base.log.info('Updating indexes for project DBs')
|
137 |
configured_dbs = set()
|
137 |
configured_dbs = set()
|
138 |
for projects in utils.chunked_find(M.Project):
|
138 |
for projects in utils.chunked_find(M.Project):
|
139 |
for p in projects:
|
139 |
for p in projects:
|
140 |
db = p.database_uri
|
140 |
db = p.database_uri
|