API for reading POTemplates attributes

Bug #525371 reported by Adi Roiban
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Adi Roiban

Bug Description

To help creating various translations statistics (ie for Ubuntu translations) it would be nice to have an LP API that could export the following information about a POTemplate:

 * template name in Launchpad
 * priority
 * length
 * date last updated
 * domain name
 * iscurrent (active or not)
 * source package
 * is in lang pack
 * in how many languages it is translates (nice to have)

The API should return a list of all templates for a series, but also the info for a single template

The requirements are tracked on this wiki page:
https://dev.launchpad.net/Translations/Specs/ReportingAPI

Related branches

Adi Roiban (adiroiban)
Changed in rosetta:
assignee: nobody → Adi Roiban (adiroiban)
Revision history for this message
Данило Шеган (danilo) wrote :

Adi, just a suggestion on how you should structure this work (you don't have to take it, but it will make it easier for everybody if you at least do similar division of work).

First, I'd do API for single PO file statistics: you'd have to worry about exporting a shared interface IRosettaStats through API, so all the other objects which are based on it will get the same API as well.

Next step would be to figure out a good API for a single potemplate and work on that. Other than the simple properties, the most interesting bit here is how do you get statistics for a bunch of attached PO files. If you don't do anything but just export a single method to list out all the PO files, you'll be doing one API call for each of the languages for a PO template and that's going to be very slow. Eg. to get full status export for Ubuntu out of LP you'd need to do some ~400k API calls.

So, a much better solution to that is to provide a method which gives you all related PO file statistics: "getPOFilesWithStatistics()" which returns tuples of form (POFile, translated_count, changed_count, unreviewed_count, untranslated_count) directly. FWIW, I'd keep this a separate step as well, so this would be bug/branch 3 already :)

And only then, as the final step, I'd do an export of IPOTemplateS(ubs)et APIs for all the different objects that have them. As another part of this step, you'd probably want to do the similar to above and provide a getPOFilesWithStatistics(language) method on them.

If you don't divide the work in this manner, you are going to end up with a gigantic branch that'll be hard to get right and get landed, and everybody will easily get lost about what exactly should be the next step.

Changed in rosetta:
importance: Undecided → High
status: New → Triaged
Adi Roiban (adiroiban)
description: updated
David Planella (dpm)
description: updated
Adi Roiban (adiroiban)
summary: - API for reading POTemplates statistics
+ API for reading POTemplates details
Adi Roiban (adiroiban)
description: updated
Revision history for this message
Adi Roiban (adiroiban) wrote : Re: API for reading POTemplates details

I have started this work by exporting only the POTemplates attributes. It is mainly the table from +templates.

I added an „all_potemplates” attribute to each series (right now only distroseries, but productseries will follow), that will list all templates from that series

ie: https://launchpad.dev/api/beta/ubuntu/hoary/all_potemplates

The link to a potemplate, is similar to the normal web URL:
https://launchpad.dev/api/beta/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/

------------------------------------------------------------------

These are the exported attributes:
active: True
all_pofiles_collection_link: https://launchpad.dev/api/beta/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/all_pofiles
description: None
exported_in_languagepacks: True
format: PO format
id: 4
languages_count: 2
last_update: 2005-05-06 21:12:13.908028+00:00
messages_count: 22
name: evolution-2.2
owner_link: https://launchpad.dev/api/beta/~rosetta-admins
path: po/evolution-2.2.pot
priority: 100
translation_domain: evolution-2.2

---------------------

The sourcepackage component name is not included as this is something very specific to Ubuntu.
I think we can have a method on a distroseries to return a list of templates that are not in main.

ie: https://launchpad.dev/api/beta/ubuntu/hoary?ws.op=getNonMainTemplates

----------------------

I would like to include the translationtarget... but since it can be IProductSeries or ISourcePackage I don't know how to declare it in lazr.restful.

Maybe we should export the sourcepackage_name as a new IPOTemplate attribute.

------------------------

all_pofiles attribute is there as an idea of how we can link pofiles.
Most probably we can not export it in API, for now.

----------------------------

The IRosettaStats is not of much use for IPOTemplate and for API in general as most of it's methods are language dependent and ... well, they are methods and we can not export them as IPOTemplate or IPOFile attributes.

This is why I skiped the first step suggested by Danilo.

----------------------------

As a next step (a new bug / new branch) I think that I should try to implement the getPOFilesWithStatistics() method on a series, as suggested by Danilo.

When you have time, please take a look at this comment and the attached branch and let me know about your feedback.

Cheers

Adi Roiban (adiroiban)
Changed in rosetta:
status: Triaged → In Progress
Adi Roiban (adiroiban)
summary: - API for reading POTemplates details
+ API for reading POTemplates attributes
Revision history for this message
Ursula Junque (ursinha) wrote : Bug fixed by a commit
Changed in rosetta:
milestone: none → 10.06
status: In Progress → Fix Committed
tags: added: qa-needstesting
tags: added: qa-ok
removed: qa-needstesting
Curtis Hovey (sinzui)
Changed in rosetta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.