def get_settings(installation, role): if role == 'admin': sql = """SELECT * FROM settings INNER JOIN setting_types ON settings.setting_name = setting_types.setting_name WHERE installation = %s ORDER BY `group`""" return backend._query(sql, installation) else: sql = """SELECT * FROM settings INNER JOIN setting_types ON settings.setting_name = setting_types.setting_name WHERE installation = %s AND `role` = %s ORDER BY `group`""" return backend._query(sql, installation, role)
def get_all(serial_number): sql = """SELECT * FROM controllers WHERE installation = %s""" return backend._query(sql, serial_number)
def get_customers(username): sql = """SELECT * FROM assignees WHERE `user` = %s;""" return backend._query(sql, username)
def get_assignees(customer_id): sql = """SELECT * FROM assignees WHERE customer = %s;""" return backend._query(sql, customer_id)
def get_all(): return backend._query("SELECT * FROM users")
def get_users_by_role(role = 'user'): sql = """SELECT * from users WHERE role = %s""" data = backend._query(sql, role) return {'users': data}
def get_log_for(installation, fromDate, toDate): sql = """SELECT * FROM log WHERE installation = %s and `time` >= %s and `time` <= %s""" return backend._query(sql, installation, fromDate, toDate)
def get_customerless(): sql = """SELECT * from installations WHERE customer IS NULL;""" return backend._query(sql)
def select_data_like(name, ip): return backend._query("""SELECT * FROM sync_queue WHERE data LIKE ? AND data LIKE ?""", '%' + name + '%', '%' + ip + '%')
def get_by_installation(installation): sql = """SELECT * FROM sync_queue WHERE installation = ?""" return backend._query(sql, installation)
def get_all(): return backend._query("""SELECT * FROM sync_queue WHERE datetime('now') > datetime(last_sync_attempt, '+10 minute') OR last_sync_attempt IS NULL""")
def get_by_installation_and_type(serial_number, type): sql = """SELECT * FROM tags WHERE `installation` = %s AND `type` = %s""" return backend._query(sql, serial_number, type)
def get_all(serial_number, controller_ip): sql = """SELECT * FROM tags WHERE `installation` = %s AND `controller_ip` = %s""" return backend._query(sql, serial_number, controller_ip)
def get_pellets_settings(installation): sql = """SELECT * FROM settings WHERE installation = %s AND setting_name IN ('internal_pelletslevel_warning', 'external_pelletslevel_warning', 'consumption_rate')""" data = backend._query(sql, installation) return data
def get_all(customer_name): sql = """SELECT * from installations WHERE customer = %s;""" return backend._query(sql, customer_name)
def get_all_setting_types(): sql = """SELECT * FROM setting_types""" data = backend._query(sql) return data
def get_by_pi_mac(pi_mac): sql = """SELECT * FROM users WHERE pi_mac = %s""" return backend._query(sql, pi_mac)
def get_all(): sql = """SELECT * FROM customers""" return backend._query(sql)