def meta(self): query = 'SELECT tactic_id, title, description, image, category FROM tactics WHERE tactic_id = ?' tup = (self.tag_id, ) data, cursor = db.execute(query, True, tup) data = cursor.fetchall() columns = ['tactic_id', 'title', 'description', 'image', 'category'] data = UserService.parseCursor(data, columns) return data
def get(self): print('invoked') query = "exec get_tactics @customer_id = ?" data, cursor = db.execute(query, True, (self.customer_id, )) data = cursor.fetchall() columns = ['title', 'description', 'tactic_id'] returned = UserService.parseCursor(data, columns) return returned
def get_tests(self): query = """SELECT * FROM get_tests(?)""" data, cursor = db.execute(query, True, (self.customer_id,)) data = cursor.fetchall() columns = [ 'views', 'conversion', 'variant', 'best_worst_binary', 'hypothesis' ] return_data = UserService.parseCursor(data, columns) return return_data
def get(self) -> dict: query = f"""exec fetch_notifications @customer_id = {self.customer_id}""" data, cursor = db.execute(query, True, ()) data = cursor.fetchall() columns = [ 'message_string', 'task_title', 'insight_body', 'message_from' ] return_data = UserService.parseCursor(data, columns) return return_data
def get_customers(self, conditional=None): query = """ SELECT * FROM customer_list """ if conditional != None: query += conditional data, cursor = db.execute(query, True, ()) data = cursor.fetchall() cursor.close() columns = [ 'name', 'email', 'company_name', 'customer_id', 'mgr', 'admin_id' ] if len(data) > 0: return_data = UserService.parseCursor(data, columns) else: null_list = [('no customers assigned yet', '', '', '', '', '')] return_data = UserService.parseCursor(null_list, columns) return return_data
def __init__(self, id, user_name, title=None): stage_1 = ['competitors', 'company', 'audience', 'product', 'product_2', 'salescycle'] stage_2 = ['goals'] stage_3 = ['history', 'platforms', 'past'] stage_4 = ['creative'] custom = ['salescycle', 'history', 'platforms'] self.id = id self.title = title self.name = user_name if self.title in stage_1: self.stage = 1 elif self.title in stage_2: self.stage = 2 elif self.title in stage_3: self.stage = 3 elif self.title in stage_4: self.stage = 4 else: self.stage = 0 def get_copy(self): query = """ SELECT * FROM dbo.everything as e WHERE e.page_title = '%s' and ( NOT EXISTS (select * from should_show(e.relevant_tags, %s)) OR e.relevant_tags IS null ) ORDER BY e.order_on_page """ % (self.title, self.id) data, cursor = db.execute(query, True, ()) data = data.fetchall() cursor.close() return data columns = ['q_id', 'page_id', 'page_title', 'page_h1', 'page_p', 'label', 'why_asking_binary', 'why_label', 'what_binary', 'what_label', 'required_binary', 'label_p', 'horizontal_separator_binary', 'container_binary', 'answer_type', 'placeholder', 'a_format', 'html_name', 'route', 'tiles_name_h6', 'tiles_name_p', 'icon_file_path', 'sub_name', 'relevant_tags', 'order_on_page', 'q_group'] if self.title not in custom: self.questions = UserService.parseCursor(get_copy(self), columns) else: self.questions = None
def GetData(self): if self.table == 'audience': params = ('persona_name', 'audience_id', self.table, self.user) elif self.table == 'product_list': params = ('name', 'p_id', self.table, self.user) query = "SELECT %s, %s FROM %s WHERE customer_id = %s" % params data, cursor = db.execute(query, True, ()) data = cursor.fetchall() column_list = ['name', 'id'] data = UserService.parseCursor(data, column_list) return data
def get_google(self, user='******'): query = """SELECT * FROM customer_ads_display(?)""" data, cursor = db.execute(query, True, (self.customer_id,)) data = cursor.fetchall() columns = [ 'agg_ctr', 'agg_cost', 'best_ctr', 'worst_ctr', 'best_headline_1', 'best_headline_2', 'best_description', 'worst_headline_1', 'worst_headline_2', 'worst_description' ] return_data = UserService.parseCursor(data, columns) return return_data