Esempio n. 1
0
 def getTop10Hashtags(self):
     dao = HashtagDAO()
     result = dao.getTop10Hashtags()
     mapped_result = []
     for r in result:
         mapped_result.append(self.mapToDict(r))
     return jsonify(Hashtag=mapped_result)
Esempio n. 2
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)
Esempio n. 3
0
 def getTrending(self):
     dao = HashtagDAO()
     result = dao.getTrending()
     mapped_result = []
     for r in result:
         mapped_result.append(self.mapTrend(r))
     return jsonify(Trending_Hashtag=mapped_result)
Esempio n. 4
0
    def getAllHashtags(self):
        hashtagDAO = HashtagDAO()
        result = hashtagDAO.getAllHashtags()

        mapped = []
        for r in result:
            mapped.append(self.mapToDict2(r))
        return jsonify(Hashtags=mapped)
Esempio n. 5
0
 def getTrendingHashtag(self):
     dao = HashtagDAO()
     result = dao.getTrendingHashtag()
     if not result:
         return jsonify(Error="Not found"), 404
     mapped_result = []
     for r in result:
         mapped_result.append(mapTrendingTopicToDict(r))
     return jsonify(mapped_result)
Esempio n. 6
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)
Esempio n. 7
0
 def insertHashtagJson(self, json):
     mtext = json["mtext"]
     mid = json["mid"]
     hashtags = self.hashes(mtext)
     dao = HashtagDAO()
     for h in hashtags:
         hid = dao.insert(h, mid)
         #result = self.buildAttributes(hid,htext)
         print(hid)
         print("\n\n\nPRINT\n\n\n")
Esempio n. 8
0
 def getAllHashtags(self):
     hashtagDAO = HashtagDAO()
     result = hashtagDAO.getAllHashtags()
     mapped = []
     for r in result:
         # hashtag_info = []
         # hashtag_info.append(r[1]) # hashtag text
         # hashtag_info.append(r[3]) # hashtag date
         mapped.append(self.mapToDict2(r))
     return jsonify(Hashtags=mapped)
Esempio n. 9
0
 def getTrends(self):
     hashtagDAO = HashtagDAO()
     result = hashtagDAO.getTrends()
     mapped = []
     for r in result:
         hashtag_info = []
         hashtag_info.append(r[0])  # hashtag date
         hashtag_info.append(r[1])  # hashtag text
         hashtag_info.append(r[2])  # hashtag count
         mapped.append(self.mapToDict3(r))
     return jsonify(Hashtags=mapped)
Esempio n. 10
0
    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)
Esempio n. 11
0
    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)
Esempio n. 12
0
    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)
Esempio n. 13
0
    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)
Esempio n. 14
0
    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)
Esempio n. 15
0
 def getHashtagById(self, hID):
     dao = HashtagDAO()
     result = dao.getHashtagsByID()
     return jsonify(result)
Esempio n. 16
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))
Esempio n. 17
0
 def getHashtagByPostId(self, pID):
     dao = HashtagDAO()
     result = dao.getHashtagByPostId()
     return jsonify(result)
Esempio n. 18
0
 def getAllHashtags(self):
     dao = HashtagDAO()
     result = dao.getAllHashtags()
     return jsonify(result)
Esempio n. 19
0
 def getTrendingHashtag(self):
     dao = HashtagDAO()
     result = dao.getTrendingHashtag()
     return jsonify(result)