Merge lp://staging/~sinzui/charmworld/api3-search into lp://staging/~juju-jitsu/charmworld/trunk

Proposed by Curtis Hovey
Status: Merged
Merged at revision: 359
Proposed branch: lp://staging/~sinzui/charmworld/api3-search
Merge into: lp://staging/~juju-jitsu/charmworld/trunk
Diff against target: 435 lines (+133/-38)
3 files modified
charmworld/health.py (+1/-1)
charmworld/views/api.py (+41/-12)
charmworld/views/tests/test_api.py (+91/-25)
To merge this branch: bzr merge lp://staging/~sinzui/charmworld/api3-search
Reviewer Review Type Date Requested Status
Brad Crittenden (community) Approve
Review via email: mp+181092@code.staging.launchpad.net

Commit message

Introduce API3.search.

Description of the change

Introduce API3.search.

RULES

    Pre-implementation: abentley, bac
    * Changes the API3.charms() method to be search() and return both
      charms and bundles.
      * Preserver API2.charms.
      * Solve the interesting() call in a future branch
    * Base this work on the API search branch from the bundles sprint.

    NEXT
    * Update index_client.api_search() provide the type of item it is
      returning.
    * Update all the callsites to unpack the item or pass doctype.

    FUTURE
    * Update interesting to support bundles.
    * Create a form to allow ~charmers to feature a bundle

QA

    * Visit http://staging.jujucharms.com/api/2/charms?owner=abentley
      * Verify the result[] contains only charms. 1 is the expected count.
    * Visit http://staging.jujucharms.com/api/3/search?owner=abentley
      * Verify the result[] contains charms and bundles. 2 is the expected
        count.

IMPLEMENTATION

I copied charms() to API2 and added
    kwargs['doctype'] = CHARM
to ensure it always specifies it wants charms. I Then renamed API3.charms()
to search. The tests were updated to call the proper endpoint. I changed
_charm_results to _item_results. item_results() knows about bundles, but
the method is incomplete. How do API consumers know what each item is?
The api_search() method isn't helping.
! Should the metadata dict contain doctype info? I think the GUI will
find something like this practical for both charms and bundles.
    metadata: {"doctype": "bundle"}
I am inclined to change the metadata in this branch if we know for certain
that API3 should do this. This would also make the tests clearer when
we can check the metadata.
    charmworld/views/api.py
    charmworld/views/tests/test_api.py

I updated the API3 health check to call the search method.
    charmworld/health.py

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Just curious, did you mean to use "_" as a dummy assignment var? I picked that up in JS but we've decide against it in Python since it can clash with real uses.

As we discussed on IRC, I think adding a 'doctype' to the metadata makes sense.

It's a shame you have to go through that non-sense to figure out if it is a bundle for looking for 'basket'.

The rest looks good. Thanks.

review: Approve
366. By Curtis Hovey

Use ignore instead of _ for ignored returns.

367. By Curtis Hovey

Added metadata.doctype = bundle to bundle json.

368. By Curtis Hovey

Added metadata.doctype = CHARM to charms.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches