← Back to team overview

launchpad-dev team mailing list archive

Re: Answers on friendly.ubuntu.com

 

On 01/16/2012 11:43 AM, Marc Tardif wrote:
> Hi folks,
> 
> The Ubuntu Friendly website [1] would like to enable people to ask
> questions about systems and we would like to use Launchpad
> Answers. The typical use case would look like:
> 
> 1. User finds system on Ubuntu Friendly;
> 2. User creates a question about the system;
> 3. Other users can see the question and answers for the system.
> 
> The problem is with the third step: how can we get the list of questions
> that were created for a given system? We thought about creating a
> title for the question when redirecting to Launchpad that could then be
> searched easily, but the user can then decide to change the title. We
> also thought about first creating a bug with a tag before creating the
> question, but that seems rather circumvoluted and not sure whether it
> would even work.
> 
> So, what would be a reasonable solution to cover the above use case?

Titles are rarely changed. Tags would be nice, but Answers does not
support them. Questions can be linked to FAQs though, and that might
help to locate questions.

Answers has an incomplete API that might help (the Purple Squad exported
the query methods to solve some maintenance problems). You can get a lot
of information about questions from the user and project perspectives. I
think exporting IFAQSet and IFAQ to permit searching and getting the
related_questions would help you. This is an example of what you can do now.

{{{
from launchpadlib.launchpad import Launchpad


def test_lp_answers():
    lp = Launchpad.login_with(
        'test', 'https://api.launchpad.net/', version='devel')
    project = lp.projects['launchpad']
    language = lp.load('+languages/en')
    indent = "    "
    sinzui = lp.people['sinzui']
    print '! Testing getDirectAnswerQuestionTargets'
    for target in sinzui.getDirectAnswerQuestionTargets():
        print indent, target.name
    print '! Testing getTeamAnswerQuestionTargets'
    for target in sinzui.getTeamAnswerQuestionTargets():
        print indent, target.name
    questions = sinzui.searchQuestions(
        status=['Open', 'Needs information'], sort='oldest first')
    for question in questions:
        print indent,  question.title
    print '! Testing findSimilarQuestions'
    for question in project.findSimilarQuestions(phrase='mbox'):
        print indent,  question.title
        print indent,  question.owner.name
        print indent,  question.date_created
    print '! Testing searchQuestions'
    questions = project.searchQuestions(
        status=['Open', 'Needs information'], language=language,
        sort='oldest first')
    for question in questions:
        print indent,  question.title
    print '! Testing question.messages'
    question = questions[3]
    for message in question.messages:
        print indent,  message.index, message.action, message.new_status
        print indent,  message.content[0:40]


if __name__ == '__main__':
    test_lp_answers()
}}}

-- 
Curtis Hovey
http://launchpad.net/~sinzui

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups

References