def getHashtagByID(self, hashtag_id): hashtagDAO = HashtagDAO() result = hashtagDAO.getHashtagById(hashtag_id) mapped = [] for r in result: # print(r) # hashtag_info = [] # hashtag_info.append(r[1]) # hashtag text # hashtag_info.append(r[3]) # hashtag date # print(hashtag_info[1]) mapped.append(self.mapToDict2(r)) return jsonify(Hashtags=mapped)
def getMessagesWithHashtag(self, hashtag_id): hashtagDAO = HashtagDAO() hasTagDAO = HasTagDAO() messageDAO = MessageDAO() result = hasTagDAO.getMessagesWithHashtag(hashtag_id) hashtag = hashtagDAO.getHashtagById(hashtag_id) mapped = [] if result == None: return jsonify(Error="MESSAGE NOT FOUND") else: for r in result: r[0] = messageDAO.getMessageById(r[0])[1] r[1] = hashtag[0] mapped.append(self.mapToDict(r)) return jsonify(Messages=mapped)
def getHashtagsFromMessage(self, message_id): hashtagDAO = HashtagDAO() hasTagDAO = HasTagDAO() messageDAO = MessageDAO() result = hasTagDAO.getHashtagsInMessage(message_id) message = messageDAO.getMessageById(message_id) mapped = [] if result == None: return jsonify(Error="HASHTAG NOT FOUND") else: for r in result: r[0] = message[1] r[1] = hashtagDAO.getHashtagById(r[1])[0] mapped.append(self.mapToDict(r)) return jsonify(Hashtags=mapped)
def getHashtagsFromMessage(self, message_id): hashtagDAO = HashtagDAO() hasTagDAO = HasTagDAO() messageDAO = MessageDAO() result = hasTagDAO.getHashtagsInMessage(message_id) if result == None: return jsonify(Error="MESSAGE NOT FOUND") else: mapped = [] for r in result: results_info = [] message_text = messageDAO.getMessageById(message_id) results_info.append(message_text[1]) # append message text hashtag_text = hashtagDAO.getHashtagById(r[1]) results_info.append(hashtag_text[0][1]) # append hashtag text mapped.append(self.mapToDict1(results_info)) return jsonify(Hashtags=mapped)
def getMessagesWithHashtag(self, hashtag_id): hashtagDAO = HashtagDAO() hasTagDAO = HasTagDAO() messageDAO = MessageDAO() result = hasTagDAO.getMessagesWithHashtagID(hashtag_id) mapped = [] if result == None: return jsonify(Error="HASHTAG NOT FOUND") else: for r in result: results_info = [] message_text = messageDAO.getMessageById(r[0]) results_info.append(message_text[1]) # append message text hashtag_text = hashtagDAO.getHashtagById(r[1]) results_info.append(hashtag_text[1]) # append hashtag text mapped.append(self.mapToDict1(results_info)) return jsonify(Messages=mapped)