def get_unread(user_id, chatroom_ids=[]): to_send = { 'messages': int(float(db_utils.execute_function("message_unread_count('%s', NULL)" % (user_id,)))), 'messages_per_chat_room': {}, 'contacts': int(float(db_utils.execute_function("contact_request_count('%s')" % (user_id,)))), 'notifications': int(float(db_utils.execute_function("notification_unread_count('%s')" % (user_id,)))) } for chatroom_id in chatroom_ids: to_send['messages_per_chat_room'][chatroom_id] = int(float( db_utils.execute_function("message_unread_count('%s', '%s')" % (user_id, chatroom_id)))) return to_send
def get_unread_notification_count(user_id): return db_utils.execute_function("notification_unread_count('%s')" % (user_id,))
def get_contact_request_count(user_id): return db_utils.execute_function("contact_request_count('%s')" % (user_id,))
def get_unread_message_count(user_id, contact_id=None): return db_utils.execute_function("message_unread_count('%s', %s)" % ( user_id, 'NULL' if contact_id is None else ("'" + contact_id + "'")))