Commit 817db35f authored by Antoine Millet's avatar Antoine Millet
Browse files

Fixed new TQL optimization.

parent 55e9b427
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -220,15 +220,11 @@ class CCServer(object):
        self._update_accounts()

        parser = TqlParser(query)
        ast, to_show, to_get = parser.parse()
        ast, to_show, to_get, to_check = parser.parse()

        to_show += show
        to_check = set()

        # Calculate the tags to get/check/show:
        if '*' in to_show:
            to_get = None

        deny = set()

        for tag in copy(to_show):
@@ -242,11 +238,6 @@ class CCServer(object):
                elif tag in to_show:
                    to_show.remove(tag)

        if to_get is not None:
            to_get -= set(self.RESERVED_TAGS)
            to_check = to_get & deny
            to_get -= to_check

        objects = OrderedSet(self.objects.all(to_get, to_check))
        if ast is not None:
            objects, _ = ast.eval(objects, objects)
@@ -254,7 +245,11 @@ class CCServer(object):
        if pure:
            return objects

        ids = [x['id'] for x in objects]
        objects = self.objects.some(ids, to_show)
            
        objects_dicts = []
        
        for obj in objects:
            objects_dicts.append(obj.to_dict(to_show, deny=deny))

+7 −3
Original line number Diff line number Diff line
@@ -623,7 +623,8 @@ class TqlParser(object):
        
        self._to_show = []
        self._to_get.clear()
        return (self._parse(), self._to_show, self._to_get)
        self._to_check.clear()
        return (self._parse(), self._to_show, self._to_get, self._to_check)

    def _parse(self):
        # Watch the next token to process:
@@ -698,6 +699,9 @@ class TqlParser(object):
                # a slice (x,y):
                right = right[1]
                self._lexer.get_token()
            elif separator[1] == '$':
                # $ separator is not handler in AST:
                right = self._lexer.get_token()[1]
            else:
                right = self._parse_word()
        else:
@@ -731,8 +735,8 @@ class TqlParser(object):
        word = self._lexer.get_token()

        # Add the tag name to the list of tags to get:
        self._to_get.add(word[1])
        self._to_show.append(word[1])
        self._to_check.add(word[1])
        self._to_show.append(left[1])

        return TqlAstTag(word[1])