Page MenuHomeSoftware Heritage

Add api_origin_metadata_search.
ClosedPublic

Authored by vlorentz on Fri, Nov 30, 1:16 PM.

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

vlorentz created this revision.Fri, Nov 30, 1:16 PM
vlorentz planned changes to this revision.Fri, Nov 30, 1:16 PM

Help wanted: currently failing, but I don't understand why. The code and tests should behave the same way as for api_origin_search

vlorentz requested review of this revision.Fri, Nov 30, 1:56 PM
zack added a subscriber: zack.Fri, Nov 30, 2:03 PM
zack added inline comments.
swh/web/api/views/origin.py
192

We should've an hardcoded max for limit: uses can specify a larger value than that, but in that case the hardcoded value would win, restricting the result set size.

vlorentz updated this revision to Diff 2383.Fri, Nov 30, 6:20 PM
  • Fix api_origin_metadata_search.
anlambert requested changes to this revision.Mon, Dec 3, 11:05 AM
anlambert added a subscriber: anlambert.
anlambert added inline comments.
swh/web/api/views/origin.py
219

You must raise a swh.web.common.exc.BadInputExc here.

An exception filter is set by the api_doc decorator that will translate it to a response with
status code 400.
By default the api endpoints must return list or dict that will get wrapped to a drf response
(see swh.web.api.apiresponse module). If you want to handle the response directly,
you must pass handle_response=True to the api_doc decorator.

This revision now requires changes to proceed.Mon, Dec 3, 11:05 AM
vlorentz updated this revision to Diff 2389.Mon, Dec 3, 11:16 AM
  • Fix error handling + add test.
vlorentz marked an inline comment as done.Mon, Dec 3, 11:17 AM
vlorentz added inline comments.
swh/web/api/views/origin.py
219

Fixed, thanks.

I also added a test for that, which fails because Django infinite-loops while handling the exception -_-

vlorentz marked an inline comment as done.Mon, Dec 3, 11:17 AM
vlorentz added inline comments.
swh/web/api/views/origin.py
219

infinite-recurses *

anlambert added inline comments.Mon, Dec 3, 11:24 AM
swh/web/tests/api/views/test_origin.py
296

You should not pass the fulltext parameter for that test to succed no ?

vlorentz updated this revision to Diff 2391.Mon, Dec 3, 11:27 AM
  • Fix test.
vlorentz marked 2 inline comments as done.Mon, Dec 3, 11:27 AM
vlorentz added inline comments.
swh/web/tests/api/views/test_origin.py
296

indeed, thanks -_-

anlambert accepted this revision.Mon, Dec 3, 11:31 AM
This revision is now accepted and ready to land.Mon, Dec 3, 11:31 AM
vlorentz updated this revision to Diff 2392.Mon, Dec 3, 11:42 AM
vlorentz marked an inline comment as done.
  • Fix limit handling.
  • Bound the limit to 100.
vlorentz marked an inline comment as done.Mon, Dec 3, 11:42 AM
vlorentz marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.