Exemplo n.º 1
0
 def get_asked_questions(self, user_id, page): 
     asked_questions = []
     results = self.retriever.get_asked_questions(user_id, self.api_site_parameter, page, pagesize= 30)
     questions = results["items"]
     pagination = utils.Pagination(results)
     for question in questions:
         asked_questions.append(Question(question['question_id'],
                                "http://%s.com/questions/%d" % (self.service, question['question_id']),
                                question['title'],
                                question['tags'], 
                                utils.date_from(question['creation_date']),
                                self.service,
                                question['up_vote_count'],
                                question['down_vote_count'],
                                question['answer_count']
                                ))
     return (asked_questions, pagination)
Exemplo n.º 2
0
 def get_questions_by_tags(self, tagged, page):
     questions_by_tags = []
     results = self.retriever.get_questions_by_tags(";".join([web.net.urlquote(tag) for tag in tagged.strip().split()]), self.api_site_parameter, page, pagesize = 30)
     questions = results["items"]
     pagination = utils.Pagination(results)
     for question in questions:
         questions_by_tags.append(Question(question['question_id'],
                                "http://%s.com/questions/%d" % (self.service, question['question_id']),
                                question['title'],
                                question['tags'],
                                utils.date_from(question['creation_date']),
                                self.service,
                                question['up_vote_count'],
                                question['down_vote_count'],
                                question['answer_count']
                                ))
     return (questions_by_tags, pagination)
Exemplo n.º 3
0
 def get_asked_questions(self, user_id, page): 
     asked_questions = []
     results = self.retriever.get_asked_questions(user_id, self.api_site_parameter, page, pagesize= 30)
     questions = results["items"]
     pagination = utils.Pagination(results)
     for question in questions:
         asked_questions.append(Question(question['question_id'],
                                "http://%s.com/questions/%d" % (self.service, question['question_id']),
                                question['title'],
                                question['tags'], 
                                utils.date_from(question['creation_date']),
                                self.service,
                                question['up_vote_count'],
                                question['down_vote_count'],
                                question['answer_count']
                                ))
     return (asked_questions, pagination)
Exemplo n.º 4
0
 def get_questions_by_tags(self, tagged, page):
     questions_by_tags = []
     results = self.retriever.get_questions_by_tags(";".join([web.net.urlquote(tag) for tag in tagged.strip().split()]), self.api_site_parameter, page, pagesize = 30)
     questions = results["items"]
     pagination = utils.Pagination(results)
     for question in questions:
         questions_by_tags.append(Question(question['question_id'],
                                "http://%s.com/questions/%d" % (self.service, question['question_id']),
                                question['title'],
                                question['tags'],
                                utils.date_from(question['creation_date']),
                                self.service,
                                question['up_vote_count'],
                                question['down_vote_count'],
                                question['answer_count']
                                ))
     return (questions_by_tags, pagination)
Exemplo n.º 5
0
 def get_answered_questions(self, user_id, page): 
     asked_questions = []
     results = self.retriever.get_user_anwers(user_id, self.api_site_parameter, page, pagesize= 30, sort = 'creation')
     answers = results["items"]
     if answers:
         pagination = utils.Pagination(results)
         question_ids = ';'.join([str(answer['question_id']) for answer in answers])
         results = self.retriever.get_questions_by_ids(question_ids, self.api_site_parameter, page, pagesize= 30)
         questions = results["items"]
     else:
         questions = []
         pagination = None
     for question in questions:
         asked_questions.append(Question(question['question_id'],
                                "http://%s.com/questions/%d" % (self.service, question['question_id']),
                                question['title'],
                                question['tags'], 
                                utils.date_from(question['creation_date']),
                                self.service,
                                question['up_vote_count'],
                                question['down_vote_count'],
                                question['answer_count']
                                ))
     return (asked_questions, pagination)
Exemplo n.º 6
0
 def get_answered_questions(self, user_id, page): 
     asked_questions = []
     results = self.retriever.get_user_anwers(user_id, self.api_site_parameter, page, pagesize= 30, sort = 'creation')
     answers = results["items"]
     if answers:
         pagination = utils.Pagination(results)
         question_ids = ';'.join([str(answer['question_id']) for answer in answers])
         results = self.retriever.get_questions_by_ids(question_ids, self.api_site_parameter, page, pagesize= 30)
         questions = results["items"]
     else:
         questions = []
         pagination = None
     for question in questions:
         asked_questions.append(Question(question['question_id'],
                                "http://%s.com/questions/%d" % (self.service, question['question_id']),
                                question['title'],
                                question['tags'], 
                                utils.date_from(question['creation_date']),
                                self.service,
                                question['up_vote_count'],
                                question['down_vote_count'],
                                question['answer_count']
                                ))
     return (asked_questions, pagination)