--- a/Allura/allura/model/index.py
+++ b/Allura/allura/model/index.py
@@ -17,6 +17,7 @@
from allura.lib import helpers as h
from .session import main_doc_session, main_orm_session
+from .project import Project
log = logging.getLogger(__name__)
@@ -131,11 +132,14 @@
# Parse all the links
parsed_links = dict((link, cls._parse_link(link)) for link in links)
links_by_artifact = defaultdict(list)
+ project_ids = set()
for link, d in parsed_links.iteritems():
+ project_ids.add(d['project_id'])
links_by_artifact[d['artifact']].append(d)
-
q = cls.query.find(dict(
- link={'$in': links_by_artifact.keys()}), validate=False)
+ link={'$in': links_by_artifact.keys()},
+ project_id={'$in': list(project_ids)}
+ ), validate=False)
result = {}
matches_by_artifact = dict(
(link, list(matches))
@@ -171,26 +175,32 @@
s = s[:-1]
parts = s.split(':')
p_shortname = None
+ p_id = None
p_nbhd = None
if hasattr(c, 'project'):
p_shortname = getattr(c.project, 'shortname', None)
+ p_id = getattr(c.project, '_id', None)
p_nbhd = c.project.neighborhood_id
if len(parts) == 3:
+ p_id = Project.query.get(shortname=parts[0])
return dict(
nbhd=p_nbhd,
project=parts[0],
+ project_id=p_id,
app=parts[1],
artifact=parts[2])
elif len(parts) == 2:
return dict(
nbhd=p_nbhd,
project=p_shortname,
+ project_id=p_id,
app=parts[0],
artifact=parts[1])
elif len(parts) == 1:
return dict(
nbhd=p_nbhd,
project=p_shortname,
+ project_id=p_id,
app=None,
artifact=parts[0])
else: