Esempio n. 1
0
 def searchHashtags(self, hname):
     dao = HashtagsDAO()
     result = dao.getHashByName(hname)
     if not result:
         return jsonify(Error='Hashtag not found.'), 404
     else:
         hashtag = self.buildHashtagAttributes(result)
         return jsonify(Hashtag=hashtag), 200
Esempio n. 2
0
 def getHashtagById(self, hid):
     dao = HashtagsDAO()
     result = dao.getHashById(hid)
     if not result:
         return jsonify(Error='Hashtag not found.'), 404
     else:
         hashtag = self.buildHashtagAttributes(result)
         return jsonify(Hashtag=hashtag), 200
Esempio n. 3
0
 def getHashtagById(self, pid):
     dao = HashtagsDAO()
     row = dao.getHashtagById(pid)
     if not row:
         return jsonify(Error="Hashtag Not Found"), 404
     else:
         hashtag = self.build_hashtag_dict(row)
         return jsonify(Hashtag=hashtag)
Esempio n. 4
0
 def getAllHashtags(self):
     dao = HashtagsDAO()
     hashtags_list = dao.getAllHashtags()
     results = []
     for row in hashtags_list:
         element = self.buildHashtagAttributes(row)
         results.append(element)
     return jsonify(Hashtag=results), 200
Esempio n. 5
0
 def getAllHashtags(self):
     dao = HashtagsDAO()
     hashtags_list = dao.getAllHashtags()
     result_list = []
     for row in hashtags_list:
         result = self.build_hashtag_dict(row)
         result_list.append(result)
     return jsonify(Hashtags=result_list)
Esempio n. 6
0
 def getTrendingHash(self):
     dao = HashtagsDAO()
     hashtags_list = dao.getTrending()
     results = []
     index = 1
     for row in hashtags_list:
         element = self.buildHashtagForTrending(row, index)
         index += 1
         results.append(element)
     return jsonify(Hashtag=results), 200
Esempio n. 7
0
 def insertHashtag(self, form):
     htext = form['htext']
     if htext:
         dao = HashtagsDAO()
         hid = dao.insert(htext)
         result = self.build_hashtag_attributes(hid, htext)
         return jsonify(Hashtag=result), 201
     else:
         return jsonify(
             Error="Unexpected attributes in hashtag request"), 400
Esempio n. 8
0
 def getTrendingTopics(self):
     dao = HashtagsDAO()
     row = dao.getTrends()
     if not row:
         return jsonify(Error="No Trends Found"), 404
     else:
         result_list = []
         for r in row:
             result = self.build_trends(r)
             result_list.append(result)
     return jsonify(Trends=result_list)
Esempio n. 9
0
    def insertHashtagJson(self, json):
        htext = json['htext']
        pid = json['pid']
        if htext and pid:
            dao = HashtagsDAO()
            hid = dao.insert(htext, pid)
            result = self.build_hashtag_attributes(hid, htext)

            return jsonify(Hashtag=result), 201
        else:
            return jsonify(
                Error="Unexpected attributes in hashtag request"), 400
Esempio n. 10
0
 def deleteHashtag(self, hid):
     dao = HashtagsDAO()
     result = dao.delete(hid)
     return jsonify(DeleteStatus="OK"), 200
Esempio n. 11
0
 def updateHashtag(self, hid, form):
     dao = HashtagsDAO()
     updatedhashtag = dao.update(hid, form)
     return jsonify(updatedhashtag), 200
Esempio n. 12
0
 def insertHashtagJson(self, json):
     dao = HashtagsDAO()
     newhashtag = dao.insert(json)
     return jsonify(newhashtag), 200
Esempio n. 13
0
 def getCountByHashtagId(self):
     dao = HashtagsDAO()
     result = dao.getCountByHashtagId()
     #print(self.build_hashtag_counts(result))
     return jsonify(HashtagCounts=self.build_hashtag_counts(result)), 200