Example #1
0
    def getMessagesWithHashtagText(self, hashtag_text):

        hashtagDAO = HashtagDAO()
        hasTagDAO = HasTagDAO()
        messageDAO = MessageDAO()

        hashtag_list = hashtagDAO.getHashtagByText(hashtag_text)
        if hashtag_list == None:
            return jsonify(Error="HASHTAG NOT FOUND")

        messages_with_tag = []
        for i in hashtag_list:
            message = hasTagDAO.getMessagesWithHashtagID(i[0])
            messages_with_tag.append(message)
        print(messages_with_tag)

        mapped = []
        for r in messages_with_tag:
            results_info = []
            results_info.append(r[0])  # append message text
            results_info.append(hashtag_text)  # append hashtag text

            mapped.append(self.mapToDict1(results_info))
        return jsonify(Messages=mapped)

        return None  #jsonify(Messages=mapped)
Example #2
0
    def getHashtagByText(self, hashtag_text):

        hashtagDAO = HashtagDAO()
        result = hashtagDAO.getHashtagByText(hashtag_text)
        mapped = []
        for r in result:

            mapped.append(self.mapToDict2(r))
        return jsonify(Hashtags=mapped)
Example #3
0
 def getHashtagByText(self, text):
     dao = HashtagDAO()
     result = dao.getHashtagByText(text)
     if result == None:
         return jsonify(Error="Not Found"), 404
     return jsonify(Hashtag=self.mapHashTagToDict(result))