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
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
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)
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
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)
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
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
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)
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
def deleteHashtag(self, hid): dao = HashtagsDAO() result = dao.delete(hid) return jsonify(DeleteStatus="OK"), 200
def updateHashtag(self, hid, form): dao = HashtagsDAO() updatedhashtag = dao.update(hid, form) return jsonify(updatedhashtag), 200
def insertHashtagJson(self, json): dao = HashtagsDAO() newhashtag = dao.insert(json) return jsonify(newhashtag), 200
def getCountByHashtagId(self): dao = HashtagsDAO() result = dao.getCountByHashtagId() #print(self.build_hashtag_counts(result)) return jsonify(HashtagCounts=self.build_hashtag_counts(result)), 200