mirror of
https://github.com/chillout2k/gulag.git
synced 2025-12-13 16:00:18 +00:00
indentation (GulagDB::get_where_clause_from_filters) problem fixed :-/
This commit is contained in:
parent
87fadeeff5
commit
72d7124602
@ -59,7 +59,8 @@ class Gulag:
|
|||||||
for arg in args:
|
for arg in args:
|
||||||
if(arg == 'query_offset' or arg == 'query_limit'
|
if(arg == 'query_offset' or arg == 'query_limit'
|
||||||
or arg == 'sort_index' or arg == 'sort_order'
|
or arg == 'sort_index' or arg == 'sort_order'
|
||||||
or arg == 'rfc822_message' or arg == 'filters'):
|
or arg == 'rfc822_message' or arg == 'filters'
|
||||||
|
or arg in self.db.vcols):
|
||||||
continue
|
continue
|
||||||
if arg not in self.fields[fields_target]:
|
if arg not in self.fields[fields_target]:
|
||||||
raise GulagException(
|
raise GulagException(
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class GulagDBException(Exception):
|
|||||||
class GulagDB:
|
class GulagDB:
|
||||||
conn = None
|
conn = None
|
||||||
uri_prefixes = None
|
uri_prefixes = None
|
||||||
vcols = None
|
vcols = {}
|
||||||
|
|
||||||
def __init__(self, args, uri_prefixes):
|
def __init__(self, args, uri_prefixes):
|
||||||
try:
|
try:
|
||||||
@ -35,12 +35,12 @@ class GulagDB:
|
|||||||
database=args['name'],
|
database=args['name'],
|
||||||
autocommit=True
|
autocommit=True
|
||||||
)
|
)
|
||||||
|
except mariadb.Error as e:
|
||||||
|
raise GulagDBException(whoami(self) + str(e)) from e
|
||||||
self.uri_prefixes = uri_prefixes
|
self.uri_prefixes = uri_prefixes
|
||||||
# virtual columns cannot not be stated in where-clause
|
# virtual columns cannot not be stated in where-clause
|
||||||
self.vcols['attach_count'] = {}
|
self.vcols['attach_count'] = {}
|
||||||
self.vcols['uri_count'] = {}
|
self.vcols['uri_count'] = {}
|
||||||
except mariadb.Error as e:
|
|
||||||
raise GulagDBException(whoami(self) + str(e)) from e
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
@ -108,8 +108,8 @@ class GulagDB:
|
|||||||
cnt += 1
|
cnt += 1
|
||||||
return where_clause
|
return where_clause
|
||||||
|
|
||||||
def get_where_clause_from_filters(self,filters_json):
|
def get_where_clause_from_filters(self,filters_json):
|
||||||
# {"groupOp":"AND","rules":[{"field":"available","op":"eq","data":"true"}]}
|
# {"groupOp":"AND","rules":[{"field":"uri_count","op":"eq","data":"3"}]}
|
||||||
filters = None
|
filters = None
|
||||||
where_clause = ""
|
where_clause = ""
|
||||||
try:
|
try:
|
||||||
@ -126,6 +126,8 @@ def get_where_clause_from_filters(self,filters_json):
|
|||||||
field_op_data = rule['field'] + " like '%" + rule['data'] + "'"
|
field_op_data = rule['field'] + " like '%" + rule['data'] + "'"
|
||||||
elif(rule['op'] == 'cn'):
|
elif(rule['op'] == 'cn'):
|
||||||
field_op_data = rule['field'] + " like '%" + rule['data'] + "%'"
|
field_op_data = rule['field'] + " like '%" + rule['data'] + "%'"
|
||||||
|
elif(rule['op'] == 'ne'):
|
||||||
|
field_op_data = rule['field'] + " <>'" + rule['data'] + "'"
|
||||||
if(field_op_data == None):
|
if(field_op_data == None):
|
||||||
raise GulagDBException(whoami(self) + "invalid rule-op: " + rule['op'])
|
raise GulagDBException(whoami(self) + "invalid rule-op: " + rule['op'])
|
||||||
if(len(filters['rules']) == 1 or len(where_clause) == 0):
|
if(len(filters['rules']) == 1 or len(where_clause) == 0):
|
||||||
|
|||||||
@ -125,4 +125,3 @@ class ResRSPAMDImporter(GulagResource):
|
|||||||
return {"resource: ": "HTTP2IMAP for RSPAMD"}
|
return {"resource: ": "HTTP2IMAP for RSPAMD"}
|
||||||
except GulagException as e:
|
except GulagException as e:
|
||||||
abort(400, message=e.message)
|
abort(400, message=e.message)
|
||||||
|
|
||||||
|
|||||||
@ -118,6 +118,11 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
description: get full RFC822 email message for each QuarMail object
|
description: get full RFC822 email message for each QuarMail object
|
||||||
|
- in: query
|
||||||
|
name: filters
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
description: jqgrid-style search filter
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: search results matching criteria
|
description: search results matching criteria
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user