Page MenuHomeSoftware Heritage

Web API: Add endpoint to list all archived software origins
ClosedPublic

Authored by anlambert on Jan 16 2019, 12:04 PM.

Details

Summary

Add a new endpoint to the Web API (/origins) in order to list all archived
software origins in a paginated way.

Related T1399
Depends on D958

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Jan 16 2019, 12:04 PM
vlorentz added inline comments.
swh/web/api/views/origin.py
78–81

You should set origin_count = results[0]['id'] - origin_from` (or something similar)

vlorentz added inline comments.Jan 16 2019, 12:24 PM
swh/web/tests/api/views/test_origin.py
339–342

Is this how example() is supposed to be used with hypothesis? It looks like it exepects that "one call of the test function = one example".

Shouldn't we ask hypothesis to build a list of origins instead?

anlambert marked 2 inline comments as done.Jan 16 2019, 1:26 PM
anlambert added inline comments.
swh/web/api/views/origin.py
78–81

There is no need to do so as origin_count corresponds to the maximum number of origins to return.

swh/web/tests/api/views/test_origin.py
339–342

The issue here is that I restrain the maximum number of examples to 1 to speedup overall tests execution.
In order to generate nb_origins origins with different values, I need to temporarily override the
max_examples hypothesis setting.

However, I agree that this code could be put in a dedicated strategy function as
I should reuse it in other tests implementation.

vlorentz added inline comments.Jan 16 2019, 1:29 PM
swh/web/api/views/origin.py
78–81

I know, but as this is the link-prev, having too many origins will make the two lists of origins overlap.

anlambert updated this revision to Diff 3056.Jan 16 2019, 1:29 PM

Update: Address vlorentz comment

anlambert marked an inline comment as done.Jan 16 2019, 1:36 PM
anlambert added inline comments.
swh/web/api/views/origin.py
78–81

Yes it can happen but I don't want to modify the origin_count parameter value.

In practice, origins should be listed from the first one to the last one so that's not really
a big issue.

vlorentz added inline comments.Jan 16 2019, 6:19 PM
swh/web/api/views/origin.py
78–81

Shouldn't we drop link-prev then?

anlambert planned changes to this revision.Jan 17 2019, 12:07 PM
anlambert marked an inline comment as done.
anlambert added inline comments.
swh/web/api/views/origin.py
78–81

Sold, will update accordingly after rebase (got some incoming changes in master branch that I want to push before landing that one).

anlambert updated this revision to Diff 3098.Jan 17 2019, 6:17 PM

Update: Rebase to master and remove the link-prev entry in api reponse Link header

anlambert updated this revision to Diff 3115.Jan 18 2019, 5:45 PM

Update: rebase to master and use better implementation for new_origins strategy

vlorentz accepted this revision.Jan 21 2019, 12:24 PM

Two more nitpicks, and it should be good!

swh/web/tests/strategies.py
172–173

You might want to check for Noneness, nb_origins might be zero on purpose (eg. when combined with other strategies that vary that parameter).

176

unique_by=lambda o: tuple(sorted(o.items()))

This revision is now accepted and ready to land.Jan 21 2019, 12:24 PM

Thanks for the review @vlorentz . I will address your last comments and land that diff.

anlambert updated this revision to Diff 3118.Jan 21 2019, 1:52 PM

Update: Address latest vlorentz comments

This revision was automatically updated to reflect the committed changes.