Exemplo n.º 1
0
 def search(**kwargs):
     return solr.get_docs_by_query_with_limit(solr.all_topics_collection(),
                                              kwargs['q'],
                                              boost='total_authority_f',
                                              fields=','.join(TopicModel.fields),
                                              qf='topic_txt_en',
                                              **sans_q(kwargs))
Exemplo n.º 2
0
    def get_authors(self, limit=10, offset=None, for_api=False):
        """
        Provides the top authors for a wiki

        :param limit: number of authors you want
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: list of author dicts
        :rtype: list
        """

        solr.get_docs_by_query_with_limit(solr.wiki_user_collection(),
                                          'wiki_id_i:%s' % self.wiki_id,
                                          limit=limit,
                                          offset=offset,
                                          sort='total_page_authority_f desc')
Exemplo n.º 3
0
    def search(**kwargs):
        """
        Accesses all wikis from database matching a query

        :return: dict keying wiki name to ids
        :rtype: dict
        """
        return solr.get_docs_by_query_with_limit(solr.global_collection(),
                                                 kwargs['q'],
                                                 fields=','.join(WikiModel.fields),
                                                 qf='attr_title^300 attr_entities^100 attr_desc^150',
                                                 **sans_q(kwargs))
Exemplo n.º 4
0
    def get_users(self, limit=10, offset=None, **kwargs):
        """
        Provides the top users for a wiki

        :param limit: number of users you want
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: list of user dicts
        :rtype: list
        """
        return solr.get_docs_by_query_with_limit(solr.wiki_user_collection(),
                                                 'wiki_id_i:%s' % self.wiki_id,
                                                 limit=limit,
                                                 offset=offset,
                                                 sort='total_page_authority_f desc',
                                                 fields=','.join(UserModel.fields))
Exemplo n.º 5
0
    def get_pages(self, limit=10, offset=None, **kwargs):
        """
        Gets most authoritative pages for this wiki

        :param limit: the number of pages you want
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: a list of page objects if not for api, otherwise an ordereddict
        :rtype: list|OrderedDict
        """

        return solr.get_docs_by_query_with_limit(solr.collection_for_wiki(self.wiki_id),
                                                 'type_s:Page',
                                                 limit=limit,
                                                 offset=offset,
                                                 sort='authority_f desc',
                                                 fields=','.join(PageModel.fields))
Exemplo n.º 6
0
    def get_topics(self, limit=10, offset=None, **kwargs):
        """
        Get topics for this wiki

        :param limit: number of topics to get
        :type limit: int|None
        :param offset: offset
        :type offset: int

        :return: a list of dicts
        :rtype: list
        """

        return solr.get_docs_by_query_with_limit(solr.collection_for_wiki(self.wiki_id),
                                                 'type_s:Topic',
                                                 limit=limit,
                                                 offset=offset,
                                                 sort='total_authority_f desc',
                                                 fields=','.join(TopicModel.fields))
Exemplo n.º 7
0
    def get_wikis(self, limit=10, offset=0, for_api=False):
        """
        Most important wikis for this user
        Calculated by sum of contribs times global authority

        :param limit: the limit
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: an ordereddict of wiki ids to wiki dicts, or a list, for API
        :rtype: collections.OrderedDict|list
        """
        return solr.get_docs_by_query_with_limit(solr.wiki_user_collection(),
                                                 'name_txt_en:%s' % self.user_name,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_contribs_authority_f')
Exemplo n.º 8
0
    def get_pages(self, limit=10, offset=0, for_api=False):
        """
        Gets top pages for this author
        calculated by contribs times global authority

        :param limit: how many you want
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: a list of dicts
        :rtype: list
        """
        return solr.get_docs_by_query_with_limit(solr.all_user_pages_collection(),
                                                 'name_txt_en:%s' % self.user_name,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='user_page_authority_f')
Exemplo n.º 9
0
    def get_pages(self, limit=10, offset=None, for_api=False):
        """
        Gets most authoritative pages for this wiki

        :param limit: the number of pages you want
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: a list of page objects if not for api, otherwise an ordereddict
        :rtype: list|OrderedDict
        """

        return solr.get_docs_by_query_with_limit(solr.collection_for_wiki(self.wiki_id),
                                                 'type_s:Page',
                                                 limit=limit,
                                                 offset=offset,
                                                 sort='authority_f desc')
Exemplo n.º 10
0
    def get_topics(self, limit=10, offset=None, for_api=False):
        """
        Get topics for this wiki

        :param limit: number of topics to get
        :type limit: int|None
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: a list of dicts
        :rtype: list
        """

        return solr.get_docs_by_query_with_limit(solr.collection_for_wiki(self.wiki_id),
                                                 'type_s:Topic',
                                                 limit=limit,
                                                 ofset=offset,
                                                 sort='total_authority_f desc')
Exemplo n.º 11
0
    def get_pages(self, limit=10, offset=0, **kwargs):
        """
        Gets top pages for this user
        calculated by contribs times global authority

        :param limit: how many you want
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: a list of dicts
        :rtype: list
        """
        return solr.get_docs_by_query_with_limit(solr.all_user_pages_collection(),
                                                 'user_id_i:%d' % self.user_id,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='user_page_authority_f',
                                                 fields=','.join(PageModel.fields),
                                                 **sans_q(kwargs))
Exemplo n.º 12
0
    def get_wikis(self, limit=10, offset=0, **kwargs):
        """
        Most important wikis for this user
        Calculated by sum of contribs times global authority

        :param limit: the limit
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: an ordereddict of wiki ids to wiki dicts, or a list, for API
        :rtype: collections.OrderedDict|list
        """
        return solr.get_docs_by_query_with_limit(solr.wiki_user_collection(),
                                                 'user_id_i:%d' % self.user_id,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_contribs_authority_f',
                                                 fields='wiki_id_i',
                                                 **sans_q(kwargs))
Exemplo n.º 13
0
    def get_pages(self, limit=10, offset=None, **kwargs):
        """
        Gets most authoritative pages for a topic using Authority DB and Wikia API data

        :param limit: Number of results we want
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: a list of objects reflecting page results
        :rtype: list
        """
        collection = solr.all_pages_collection()
        return solr.get_docs_by_query_with_limit(collection,
                                                 self.topic,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_authority_f',
                                                 fields=','.join(PageModel.fields),
                                                 **sans_q(kwargs))
Exemplo n.º 14
0
    def get_users(self, limit=10, offset=0, **kwargs):
        """
        Gets users for a given topic

        :param limit: the number of users we want
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: a list of objects related to authors
        :rtype: list
        """

        collection = solr.user_collection()
        return solr.get_docs_by_query_with_limit(collection,
                                                 self.topic,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_authority_f',
                                                 fields=','.join(UserModel.fields),
                                                 **sans_q(kwargs))
Exemplo n.º 15
0
    def get_pages(self, limit=10, offset=None, for_api=False):
        """
        Gets most authoritative pages for a topic using Authority DB and Wikia API data

        :param limit: Number of results we want
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: a list of objects reflecting page results
        :rtype: list
        """

        collection = solr.all_pages_collection()
        return solr.get_docs_by_query_with_limit(collection,
                                                 self.topic,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_authority_f')
Exemplo n.º 16
0
    def get_wikis(self, limit=10, offset=0, for_api=False):
        """
        Gets wikis for the current topic

        :param limit: the number of wikis we want
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: a dict with keys for wikis (objects) and wiki ids (ints) for ordering or an ordered list of dicts
        :rtype: dict|list
        """

        collection = solr.global_collection()
        return solr.get_docs_by_query_with_limit(collection,
                                                 self.topic,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_authority_f')
Exemplo n.º 17
0
    def get_users(self, limit=10, offset=0, for_api=False):
        """
        Gets users for a given topic

        :param limit: the number of users we want
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: a list of objects related to authors
        :rtype: list
        """

        collection = solr.user_collection()
        return solr.get_docs_by_query_with_limit(collection,
                                                 self.topic,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_authority_f')
Exemplo n.º 18
0
    def get_wikis(self, limit=10, offset=0, **kwargs):
        """
        Gets wikis for the current topic

        :param limit: the number of wikis we want
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: a dict with keys for wikis (objects) and wiki ids (ints) for ordering or an ordered list of dicts
        :rtype: dict|list
        """

        collection = solr.global_collection()
        return solr.get_docs_by_query_with_limit(collection,
                                                 self.topic,
                                                 limit=limit,
                                                 offset=offset,
                                                 boost='scaled_authority_f',
                                                 qf='attr_title^300 attr_entities^100 attr_desc^150',
                                                 fields=','.join(WikiModel.fields),
                                                 **sans_q(kwargs))
Exemplo n.º 19
0
    def get_users(self, limit=10, offset=0, **kwargs):
        """
        Get the most authoritative users for this page

        :param limit: the number of users you want
        :type limit: int
        :param offset: offset
        :type offset: int

        :return: a list of of user dicts in order of authority
        :rtype: list
        """

        return solr.get_docs_by_query_with_limit(
            solr.collection_for_wiki(self.wiki_id),
            'type_s:PageUser AND doc_id_s:%s' % (self.doc_id),
            limit=limit,
            offset=offset,
            boost='contribs_f',
            fields=','.join(UserModel.fields),
            **sans_q(kwargs)
        )
Exemplo n.º 20
0
    def get_users(self, limit=10, offset=0, for_api=False):
        """
        Get the most authoritative users for this page

        :param limit: the number of users you want
        :type limit: int
        :param offset: offset
        :type offset: int
        :param for_api: if it's for the api, we add less
        :type for_api: bool

        :return: a list of of user dicts in order of authority
        :rtype: list
        """

        return solr.get_docs_by_query_with_limit(
            solr.collection_for_wiki(self.wiki_id),
            'type_s:PageUser AND doc_id_s:%s_%s' % (str(self.wiki_id), str(self.page_id)),
            limit=limit,
            offset=offset,
            boost='contribs_f'
        )
Exemplo n.º 21
0
 def search(**kwargs):
     return solr.get_docs_by_query_with_limit(solr.user_collection(),
                                              kwargs['q'],
                                              boost='scaled_authority_f',
                                              fields=','.join(UserModel.fields),
                                              **sans_q(kwargs))