From 6aafba52d7a3f6f03b85d9df35972eb6564d36ed Mon Sep 17 00:00:00 2001 From: Kristofer Hallin Date: Wed, 6 Oct 2021 21:48:53 +0200 Subject: Create indexes when creating database, also make it possible to search based on indexes. --- src/wsgi.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/wsgi.py') diff --git a/src/wsgi.py b/src/wsgi.py index e1f645c..54d18d3 100755 --- a/src/wsgi.py +++ b/src/wsgi.py @@ -4,6 +4,7 @@ import os import sys import json import authn +import index import falcon from db import DictDB @@ -46,7 +47,9 @@ class CollectorResource(): class EPGet(CollectorResource): def on_get(self, req, resp): - out = [] + out = list() + selectors = dict() + resp.status = falcon.HTTP_200 resp.content_type = falcon.MEDIA_JSON orgs = self.user_auth(req.auth, self._users.read_perms) @@ -57,9 +60,11 @@ class EPGet(CollectorResource): {'status': 'error', 'message': 'Invalid username or password\n'}) return - # We really shouldn't rely on req.params in its pure form since - # it might contain garbage. - selectors = req.params + for param in req.params: + for i in index.indexes: + for j in i['index']['fields']: + if j == param: + selectors[param] = req.params[param] for org in orgs: selectors['domain'] = org -- cgit v1.1