Exemple #1
0
    def getAllReplies(self):

        replyDAO = ReplyDAO()
        dao1 = MessageDAO()
        dao2 = MessageDAO()
        sentDAO = SentDAO()
        messagesDAO = MessagesDAO()

        result = replyDAO.getAllReplies()  # get all messages that are replies
        mapped_result = []  #store all replies mapped

        for r in result:

            reply_info = []

            owner_message = dao1.getMessageById(r[0])  # original message info
            reply_message = dao2.getMessageById(r[1])  # reply message info

            reply_info.append(reply_message[1])  # append reply text
            reply_info.append(owner_message[1])  # append original message

            replyer_name = sentDAO.getUserByMessageId(
                reply_message[0])  # get replyer name
            reply_info.append(replyer_name[1] + ' ' +
                              replyer_name[2])  # append name

            chat_name = messagesDAO.getChatByMessageId(
                r[0])  # what group was the reply sent
            reply_info.append(chat_name[1])  # append group chat name

            reply_info.append(reply_message[2])  # append reply_date
            reply_info.append(owner_message[2])  # append original_message_date

            mapped_result.append(self.mapToDict(reply_info))
        return jsonify(Replies=mapped_result)
Exemple #2
0
 def getAllReplies(self):
     dao = ReplyDAO()
     result = dao.getAllReplies()
     mapped_result = []
     for r in result:
         mapped_result.append(self.mapToDict(r))
     return jsonify(Replies=mapped_result)
Exemple #3
0
    def getAllReplies(self):
        dao = ReplyDAO()
        dao1 = MessageDAO()
        dao2 = MessageDAO()
        userDAO = UserDAO()
        chatDAO = ChatDAO()
        result = dao.getAllReplies()
        mapped_result = []
        for r in result:
            reply_info = []
            result1 = dao1.getMessageById(r[0])  # array de mensaje-reply
            result2 = dao2.getMessageById(r[1])  # array de mensaje original
            reply_info.append(result1[1]) #replyer_text
            reply_info.append(result2[1]) #original_text
            # buscar user con user id
            # result1[3] - replyer_id
            replyer = userDAO.getUserById(result1[3])

            reply_info.append(replyer[1] + ' ' +replyer[2])

            # buscar chat con chat id
            # result1[4] - chat_id
            chat_name = chatDAO.getChatById(result1[4])
            reply_info.append(chat_name[1])

            reply_info.append(result1[2]) #reply_date
            reply_info.append(result2[2]) #original_message_date

            mapped_result.append(self.mapToDict(reply_info))
        return jsonify(Replies=mapped_result)
Exemple #4
0
 def getAllReplies2(self):
     dao = ReplyDAO()
     dao1 = UserDAO()
     dao2 = MessageDAO()
     result = dao.getAllReplies()
     mapped_result = []
     for r in result:
         result1 = dao1.getUserById(r[1])
         result2 = dao2.getMessageById(r[2])
         r[1] = result1[1] + " " + result1[2]
         r[2] = result2[1]
         mapped_result.append(self.mapToDict2(r))
     return jsonify(Replies=mapped_result)