示例#1
0
 def search(self,
            q=None,
            history=False,
            project=False,
            limit=None,
            page=0,
            **kw):
     'local tool search'
     if project:
         redirect(c.project.url() + 'search?' +
                  urlencode(dict(q=q, history=history)))
     results = []
     count = 0
     limit, page, start = g.handle_paging(limit, page, default=25)
     if not q:
         q = ''
     else:
         results = search(
             q,
             rows=limit,
             start=start,
             fq=[
                 'is_history_b:%s' % history,
                 'project_id_s:%s' % c.project._id,
                 'mount_point_s:%s' % c.app.config.options.mount_point,
                 '-deleted_b:true'
             ])
         if results: count = results.hits
     c.search_results = self.W.search_results
     return dict(q=q,
                 history=history,
                 results=results or [],
                 count=count,
                 limit=limit,
                 page=page)
示例#2
0
 def search(self, q=None, history=False, project=False, limit=None, page=0, **kw):
     'local tool search'
     if project:
         redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
     results = []
     count=0
     limit, page, start = g.handle_paging(limit, page, default=25)
     if not q:
         q = ''
     else:
         results = search(
             q, rows=limit, start=start,
             fq=[
                 'is_history_b:%s' % history,
                 'project_id_s:%s' % c.project._id,
                 'mount_point_s:%s'% c.app.config.options.mount_point,
                 '-deleted_b:true'])
         if results: count=results.hits
     c.search_results = self.W.search_results
     if results is not None:
         for doc in results:
             if doc.get('type_s', '') == 'Post':
                 _id = doc.get('id').split('#')
                 _id = _id[-1].replace('/', '.') if _id else ''
                 p = model.ForumPost.query.get(_id=_id)
                 doc['url_paginated'] = p.url_paginated()
     return dict(q=q, history=history, results=results or [],
                 count=count, limit=limit, page=page)
示例#3
0
    def search(self,
               q=None,
               history=None,
               project=None,
               limit=None,
               page=0,
               **kw):
        if project:
            redirect(c.project.url() + 'search?' +
                     urlencode(dict(q=q, history=history)))
        results = []
        count = 0
        limit, page, start = g.handle_paging(limit, page, default=25)
        if not q:
            q = ''
        else:
            query = [
                'is_history_b:%s' % history,
                'project_id_s:%s' % c.project._id,
                'mount_point_s:%s' % c.app.config.options.mount_point,
                'type_s:%s' % ShortUrl.type_s
            ]
            if not has_access(c.app, 'view_private'):
                query.append('private_b:False')
            results = search(q, fq=query)

            if results:
                count = results.hits
        c.search_results = W.search_results
        return dict(q=q,
                    history=history,
                    results=results or [],
                    count=count,
                    limit=limit,
                    page=page)
示例#4
0
    def search(self, q=None,
               history=None, project=None,
               limit=None, page=0, **kw):
        if project:
            redirect(c.project.url() +
                     'search?' +
                     urlencode(dict(q=q, history=history)))
        results = []
        count = 0
        limit, page, start = g.handle_paging(limit, page, default=25)
        if not q:
            q = ''
        else:
            query = ['is_history_b:%s' % history,
                    'project_id_s:%s' % c.project._id,
                    'mount_point_s:%s' % c.app.config.options.mount_point,
                    'type_s:%s' % ShortUrl.type_s]
            if not has_access(c.app, 'view_private'):
                query.append('private_b:False')
            results = search(q, fq=query)

            if results:
                count = results.hits
        c.search_results = W.search_results
        return dict(q=q, history=history, results=results or [],
                    count=count, limit=limit, page=page)
示例#5
0
 def index(self, q=None, history=False, **kw):
     results = []
     count=0
     if not q:
         q = ''
     else:
         results = search.search(
             q,
             fq='is_history_b:%s' % history)
         if results: count=results.hits
     return dict(q=q, history=history, results=results or [], count=count)
示例#6
0
文件: main.py 项目: Bitergia/allura
 def search(self, q=None, history=None, **kw):
     'local tool search'
     results = []
     count=0
     if not q:
         q = ''
     else:
         results = search(
             q,
             fq=[
                 'is_history_b:%s' % history,
                 'project_id_s:%s' % c.project._id,
                 'mount_point_s:%s'% c.app.config.options.mount_point ])
         if results: count=results.hits
     return dict(q=q, history=history, results=results or [], count=count)
示例#7
0
 def search(self, q=None, history=None, **kw):
     'local tool search'
     results = []
     count=0
     if not q:
         q = ''
     else:
         results = search(
             q,
             fq=[
                 'is_history_b:%s' % history,
                 'project_id_s:%s' % c.project._id,
                 'mount_point_s:%s'% c.app.config.options.mount_point ])
         if results: count=results.hits
     return dict(q=q, history=history, results=results or [], count=count)
示例#8
0
 def index(self, q=None, history=None, **kw):
     results = []
     count=0
     if not q:
         q = ''
     else:
         pids = [c.project._id] + [
             p._id for p in c.project.subprojects ]
         project_match = ' OR '.join(
             'project_id_s:%s' % pid
             for pid in pids )
         search_query = '%s AND is_history_b:%s AND (%s) AND -deleted_b:true' % (
             q, history, project_match)
         results = search.search(search_query, is_history_b=history)
         if results: count=results.hits
     return dict(q=q, history=history, results=results or [], count=count)
示例#9
0
文件: search.py 项目: brondsem/allura
def query_filter_choices(arg=None, fq=[]):
    """
    Makes solr query and returns facets for tickets.

    :param arg: solr query, string
    """
    params = {
        'short_timeout': True,
        'fq': [
            'project_id_s:%s' % c.project._id,
            'mount_point_s:%s' % c.app.config.options.mount_point,
            'type_s:Ticket',
            ] + fq,
        'rows': 0,
    }
    params.update(FACET_PARAMS)
    result = search(arg, **params)
    return get_facets(result)
示例#10
0
def query_filter_choices(arg=None):
    """
    Makes solr query and returns facets for tickets.

    :param arg: solr query, string
    """
    params = {
        'short_timeout': True,
        'fq': [
            'project_id_s:%s' % c.project._id,
            'mount_point_s:%s' % c.app.config.options.mount_point,
            'type_s:Ticket',
            ],
        'rows': 0,
    }
    params.update(FACET_PARAMS)
    result = search(arg, **params)
    return get_facets(result)
示例#11
0
 def search(self,
            q=None,
            history=False,
            project=False,
            limit=None,
            page=0,
            **kw):
     'local tool search'
     if project:
         redirect(c.project.url() + 'search?' +
                  urlencode(dict(q=q, history=history)))
     results = []
     count = 0
     limit, page, start = g.handle_paging(limit, page, default=25)
     if not q:
         q = ''
     else:
         results = search(
             q,
             rows=limit,
             start=start,
             fq=[
                 'is_history_b:%s' % history,
                 'project_id_s:%s' % c.project._id,
                 'mount_point_s:%s' % c.app.config.options.mount_point,
                 '-deleted_b:true'
             ])
         if results: count = results.hits
     c.search_results = self.W.search_results
     if results is not None:
         for doc in results:
             if doc.get('type_s', '') == 'Post':
                 _id = doc.get('id').split('#')
                 _id = _id[-1].replace('/', '.') if _id else ''
                 p = model.ForumPost.query.get(_id=_id)
                 doc['url_paginated'] = p.url_paginated()
     return dict(q=q,
                 history=history,
                 results=results or [],
                 count=count,
                 limit=limit,
                 page=page)
示例#12
0
 def search(self, q=None, history=None, project=None, limit=None, page=0, **kw):
     'local wiki search'
     if project:
         redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
     results = []
     count=0
     limit, page, start = g.handle_paging(limit, page, default=25)
     if not q:
         q = ''
     else:
         results = search(
             q, rows=limit, start=start,
             fq=[
                 'is_history_b:%s' % history,
                 'project_id_s:%s' % c.project._id,
                 'mount_point_s:%s'% c.app.config.options.mount_point,
                 '-deleted_b:true'])
         if results: count=results.hits
     c.search_results = W.search_results
     return dict(q=q, history=history, results=results or [],
                 count=count, limit=limit, page=page)