GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 531f41...661b81 )
by Chathan
01:10
created

simple_forums.backends.search.SimpleSearch   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %
Metric Value
wmc 6
dl 0
loc 25
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A SimpleSearch.wipe() 0 2 1
A SimpleSearch.search() 0 13 3
A SimpleSearch.add() 0 2 1
A SimpleSearch.remove() 0 2 1
1
from functools import reduce
2
3
from django.db.models import Q
4
5
from simple_forums import models
6
from simple_forums.backends.search import BaseSearch, SearchResultSet
7
8
9
class SimpleSearch(BaseSearch):
10
    """ Simple ORM based search """
11
12
    def add(self, object):
13
        """ Not implemented in this backend """
14
15
    def remove(self, object):
16
        """ Not implemented in this backend """
17
18
    def search(self, query_string):
19
        """ Search all thread instances for the given query string """
20
        threads = models.Thread.objects.filter(
21
            reduce(
22
                lambda q, f: q & Q(title__icontains=f),
23
                query_string.split(),
24
                Q()))
25
26
        result_set = SearchResultSet()
27
        for thread in threads:
28
            result_set.add(thread)
29
30
        return result_set
31
32
    def wipe(self):
33
        """ Not implemented in this backend """
34