def getTrendingHashtags(): tophashtags = [] hashtags = dao.getTrendingHashtags() for row in hashtags: result = Dict.dashboard_hashtag_dict(row) tophashtags.append(result) return jsonify(Hashtags=tophashtags)
def getPostsByChatIDForUI(chat_id): chat_post_messages = dao.getPostsByChatID(chat_id) result_post_messages = [] for row in chat_post_messages: result_post_messages.append( Dict.post_msg_chat_dict_UI_2(row, getRepliesByPostIDForUI(row[1]))) return jsonify(PostsInChat=result_post_messages)
def getUserContactsByID(user_id): result = dao.getUserContactsByID(user_id) if not result: return jsonify(Error="No Contacts Found"), 404 mapped_result = [] for row in result: mapped_result.append(Dict.contacts_dict(row)) return jsonify(UserContacts=mapped_result)
def getAllPost(): rows = dao.getAllPosts() if not rows: return jsonify(Error="No Message found"), 404 result = [] for row in rows: result.append(Dict.post_dict(row)) return jsonify(Posts=result)
def getUserActivity(user_id): result = dao.getUserActivity(user_id) if not result: return jsonify(Error="No Activity Found"), 404 mapped_result = [] for row in result: mapped_result.append(Dict.activity_dict(row)) return jsonify(UserActivity=result)
def getAllUsers(): result = dao.getAllUsers() if not result: return jsonify(Error="No Users Found"), 404 mapped_result = [] for row in result: mapped_result.append(Dict.user_dict(row)) return jsonify(Users=mapped_result)
def getAllCredentials(): result = dao.getAllCredentials() if not result: return jsonify(Error="No Credentials Found"), 404 mapped_result = [] for row in result: mapped_result.append(Dict.credential_dict(row)) return jsonify(Credentials=mapped_result)
def getAllActivity(): result = dao.getAllActivity() if not result: return jsonify(Error="No Activity Found"), 404 mapped_result = [] for row in result: mapped_result.append(Dict.activity_dict(row)) return jsonify(Activity=mapped_result)
def getChatByUserID(user_id): rows = dao.getChatByUserID(user_id) if not rows: return jsonify(Error="No Chats found"), 404 result = [] for row in rows: result.append(Dict.chat_dict(row)) return jsonify(Chats=result)
def getUsersWhoDislikedPost(post_id): result = dao.getUsersWhoDislikedPost(post_id) if not result: return jsonify(Error="No Users Found"), 404 mapped_result = [] for row in result: mapped_result.append(Dict.reaction_user_dict(row)) return jsonify(UsersDislikedPost=mapped_result)
def getUsersByChatID(chat_id): result = dao.getUsersByChatID(chat_id) if not result: return jsonify(Error="No Users Found"), 404 mapped_result = [] for row in result: mapped_result.append(Dict.chat_participants_dict(row)) return jsonify(Users=mapped_result)
def getRepliesByPostID(post_id): replies_info = dao.getRepliesByPostID(post_id) if not replies_info: return jsonify(Error="No Replies Found"), 404 result_replies = [] for row in replies_info: result = Dict.reply_dict(row) result_replies.append(result) return jsonify(Replies=result_replies)
def getPostsByChatID(chat_id): chat_post_messages = dao.getPostsByChatID(chat_id) if not chat_post_messages: return jsonify(Error="No Messages Found") result_post_messages = [] for row in chat_post_messages: result = Dict.post_msg_chat_dict_UI(row) result_post_messages.append(result) return jsonify(PostsInChat=result_post_messages)
def getPostPerDay(): postsPerDay = dao.getPostPerDay() result_list = [] for row in postsPerDay: result = Dict.post_per_day_dict(row) result_list.append(result) return jsonify(PostsPerDay=result_list)
def getMediaByPostID(post_id): media_info = dao.getMediaByPostID(post_id) if not media_info: return jsonify(Error="No Messages Found"), 404 result_media = [] for row in media_info: result = Dict.media_dict(row) result_media.append(result) return jsonify(Media=result_media)
def getAllChats(): chat_lists = dao.getAllChats() if not chat_lists: return jsonify(Error="No Chats Found") result_list = [] for row in chat_lists: result = Dict.chat_dict(row) result_list.append(result) return jsonify(Chats=result_list)
def getUserInfo(user_id): result = dao.getUserInfo(user_id) if not result: return jsonify(Error="No User Found"), 404 result = Dict.user_dict(result) return jsonify(UserInfo=result)
def getAdminByChatID(chat_id): result = dao.getAdminByChatID(chat_id) if not result: return jsonify(Error="No Admin Found"), 404 mapped_result = Dict.chat_admin_dict(result) return jsonify(Admin=mapped_result)
def getRepliesByPostIDForUI(post_id): replies_info = dao.getRepliesByPostID(post_id) result_replies = [] for row in replies_info: result_replies.append(Dict.reply_dict(row)) return result_replies