Merge lp:~linaro-infrastructure/launchpad/workitems-parsing-and-updating into lp:launchpad
Proposed by
Guilherme Salgado
Status: | Merged |
---|---|
Approved by: | Abel Deuring |
Approved revision: | no longer in the source branch. |
Merged at revision: | 14868 |
Proposed branch: | lp:~linaro-infrastructure/launchpad/workitems-parsing-and-updating |
Merge into: | lp:launchpad |
Diff against target: |
324 lines (+235/-3) 4 files modified
lib/lp/blueprints/interfaces/specification.py (+22/-0) lib/lp/blueprints/model/specification.py (+63/-0) lib/lp/blueprints/model/tests/test_specification.py (+149/-2) lib/lp/registry/model/milestone.py (+1/-1) |
To merge this branch: | bzr merge lp:~linaro-infrastructure/launchpad/workitems-parsing-and-updating |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Abel Deuring (community) | code | Approve | |
Review via email: mp+94552@code.launchpad.net |
Commit message
[r=adeuring][bug=940446] new method Specification.
Description of the change
This branch adds a new method on ISpecification which will take a list of dictionaries describing work items and update/
In lp:~linaro-infrastructure/launchpad/workitems-widget we're implementing a new field class which will parse the work items entered by the user into the list of dicts expected by updateWorkItems()
To post a comment you must log in.
Hi Salgado,
the changes look good overall, I just have a few formal nitpicks, see below.
> + def updateWorkItems (new_work_ items):
> + """Update the existing work items to match the given ones.
> +
> + First, for every existing work item that is not present on the new
> + list, mark it as deleted. Then, for every tuple in the given list,
s/tuple/dictionary/
> + lookup an existing work item with the same title and update its
> + status, assignee, milestone and sequence (position on the work-items
> + list). If there's no existing work items with that title, we create a
> + new one.
> +
> + :param new_work_items: A list of dictionaries containing the following
> + keys: title, status, assignee and milestone.
> + """
> + def _deleteWorkItem sNotMatching( self, titles):
> + """Delete all work items whose title does not match the given ones.
> +
> + Also set the sequence of those deleted work items to -1.
> + """
Since the work item will not literally be deleted, I think "Mark all
work items as deleted" is a bit more precise than "Delete all work items"
> + for work_item in self.work_items: (self, new_work_items): kItemsNotMatchi ng( self).find( rkItem, specification=self, deleted=False) items.order_ by("sequence" )) new_work_ items)) :
> + if work_item.title not in titles:
> + work_item.deleted = True
> +
> + def updateWorkItems
> + """See ISpecification."""
> + # First mark work items with titles that are no longer present as
> + # deleted.
> + self._deleteWor
> + [wi['title'] for wi in new_work_items])
> + work_items = Store.of(
> + SpecificationWo
> + work_items = list(work_
> + # At this point the list of new_work_items is necessarily the same
> + # size (or longer) than the list of existing ones, so we can just
> + # iterate over it updating the existing items and creating any new
> + # ones.
> + to_insert = []
> + existing_titles = [wi.title for wi in work_items]
> + for i in range(len(
Our style guide does not allow single-letter variable names. WHat about
"for position in..." or "for index in..."?