From f8b2b6ce776648039323870af35efafe03494f74 Mon Sep 17 00:00:00 2001 From: wuaho Date: Thu, 9 Sep 2021 18:21:44 +0800 Subject: [PATCH] 1 --- models/user_analysis.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/models/user_analysis.py b/models/user_analysis.py index e71a8c0..fe0d646 100644 --- a/models/user_analysis.py +++ b/models/user_analysis.py @@ -28,7 +28,7 @@ class UserAnalysis: self.zone_time: int = 0 self.data_in = data_in - self.global_filters = None + self.global_filters = [] self.groupby = None self.time_particle = None self.date_range = None @@ -106,6 +106,16 @@ class UserAnalysis: elif comparator == '!=': where.append(col != ftv[0]) + elif comparator == 'like': + where.append(col.like(f'%{ftv[0]}%')) + + elif comparator == 'not like': + where.append(col.notlike(f'%{ftv[0]}%')) + + elif comparator == 'in': + where.append(col.in_(ftv)) + + return where def property_model(self): @@ -129,7 +139,7 @@ class UserAnalysis: func.round(getattr(func, analysis)(getattr(self.user_tbl.c, event['quota'])), 2).label( 'values')] - where = self._get_filters(event['filts']) + where = self._get_filters(event['filts']+self.global_filters) qry = sa.select((*self.groupby, *selectd)).where(*where) qry = qry.group_by(*self.groupby)