Exemplo n.º 1
0
 def get_total_dislikes_per_day(self):
     dao = ReactionsDAO()
     dislikes = dao.get_dislikes_per_day()
     result_list = []
     for row in dislikes:
         result = self.build_total_dict(row)
         result_list.append(result)
     return jsonify(result_list)
Exemplo n.º 2
0
 def getUsersWhoDislikesByMessageId(self, messageId):
     dao = ReactionsDAO()
     reaction_list = dao.getUsersWhoDislikesByMessageId(messageId)
     results = []
     for row in reaction_list:
         result = self.buildUserReactionDictionary(row)
         results.append(result)
     return jsonify(results), 200
Exemplo n.º 3
0
 def get_users_that_disliked(self, mid):
     dao = ReactionsDAO()
     users = dao.get_users_that_disliked_message(mid)
     result = []
     for user in users:
         dict = self.build_user_dict(user)
         result.append(dict)
     return jsonify(result)
Exemplo n.º 4
0
 def get_user_reaction(self, mid, uid):
     dao = ReactionsDAO()
     row = dao.get_user_reaction(mid, uid)
     if not row:
         return jsonify(False)
     else:
         reaction = self.build_reaction_dict(row)
         return jsonify(reaction)
Exemplo n.º 5
0
 def getAllReactions(self):
     dao = ReactionsDAO()
     reaction_list = dao.getAllReactions()
     results = []
     for row in reaction_list:
         element = self.buildReactionDictionary(row)
         results.append(element)
     return jsonify(results), 200
Exemplo n.º 6
0
 def getReactionById(self, rid):
     dao = ReactionsDAO()
     reaction = dao.get_reaction_by_id(rid)
     if not reaction:
         return jsonify(Error="Reaction not found"), 404
     else:
         result = self.build_reaction_dict(reaction)
         return jsonify(Reaction=reaction)
Exemplo n.º 7
0
 def getReactions(self):
     dao = ReactionsDAO()
     reactions = dao.get_all_reactions()
     result = []
     for row in reactions:
         dict = self.build_reaction_dict(row)
         result.append(dict)
     return jsonify(Reactions=result)
Exemplo n.º 8
0
 def get_number_of_dislikes(self, mid):
     dao = ReactionsDAO()
     message_dao = MessagesDAO()
     message = message_dao.get_message(mid)
     if not message:
         return jsonify(Error="Message does not exist"), 404
     else:
         message_dislikes = dao.get_number_of_dislikes_by_mid(mid)
         return jsonify(message_dislikes)
Exemplo n.º 9
0
 def getAllReactionsForMessages(self):
     dao = ReactionsDAO()
     reaction_list = dao.reactionsPerMessage()
     # results = self.buildReactionDictionary(reaction_list)
     # return jsonify(results), 200
     results = []
     for row in reaction_list:
         element = self.buildReactionDictionary(row)
         results.append(element)
     return jsonify(results), 200
Exemplo n.º 10
0
 def insert_reaction(self, form, uid, mid):
     if len(form) != 2:
         return jsonify(Error="Number of attributes different from 2"), 400
     else:
         rlike = form['rlike']
         rdislike = form['rdislike']
         if rlike and rdislike:
             dao = ReactionsDAO()
             row = dao.insert_reaction(rlike, rdislike, mid, uid)
             rid = row[0]
             rdate = row[1]
             result = self.build_reaction_dict_attr(rid, rlike, rdislike, mid, uid, rdate)
             return jsonify(result)
         else:
             return jsonify(Error="Malformed post request"), 404
Exemplo n.º 11
0
 def updateReactionById(self, rid, form):
     if len(form) != 2:
         return jsonify(Error="Number of attributes different from 2"), 400
     else:
         rlike = form['rlike']
         rdislike = form['rdislike']
         if rlike and rdislike:
             dao = ReactionsDAO()
             row = dao.get_reaction_by_id(rid)
             if not row:
                 return jsonify(Error="Reaction not found"), 404
             else:
                 result = dao.update_reaction(rid, rlike, rdislike)
                 return jsonify(Status=result), 201
         else:
             return jsonify(Error="Unexpected attributes in update request"), 400
Exemplo n.º 12
0
 def getDislikesCountByMessageId(self, messageId):
     dao = ReactionsDAO()
     count = dao.getDislikesCountByMessageId(messageId)
     result = self.buildDislikesCountDictionary(count)
     return jsonify(result), 200
Exemplo n.º 13
0
 def getDislikesOfPost(self, postId):
     dao = ReactionsDAO()
     count = dao.getDislikesOfPost(postId)
     return jsonify(DislikesOnPost=count)
Exemplo n.º 14
0
 def getDislikesCountOnDate(self, date):
     dao = ReactionsDAO()
     count = dao.getDislikesCountOnDate(date)
     return jsonify(DislikesOnDate=count), 200
Exemplo n.º 15
0
 def deleteReaction(self, cid):
     dao = ReactionsDAO()
     id = dao.delete(cid)
     return jsonify(DeleteStatus="OK"), 200
Exemplo n.º 16
0
 def searchReactions(self, args):
     dao = ReactionsDAO()
     reaction_list = dao.getReactionsByArgs(args)
     return jsonify(reaction_list), 200
Exemplo n.º 17
0
 def get_total_likes(self):
     dao = ReactionsDAO()
     total_likes = dao.get_total_likes()
     return jsonify(Likes=total_likes)
Exemplo n.º 18
0
 def getReactionById(self, cid):
     dao = ReactionsDAO()
     reaction = dao.getReactionById(cid)
     return jsonify(reaction), 200
Exemplo n.º 19
0
 def insertReactionJson(self, json):
     dao = ReactionsDAO()
     newreaction = dao.insert(json)
     return jsonify(newreaction), 200
Exemplo n.º 20
0
 def updateReaction(self, cid, form):
     dao = ReactionsDAO()
     updatedreaction = dao.update(cid, form)
     return jsonify(updatedreaction), 200