transition-zero / tz-client

A client repository for accessing FEO data programmatically.
https://docs.feo.transitionzero.org
Apache License 2.0
21 stars 4 forks source link

BUG: Page 0 and 1 of an Asset search sometimes share items #55

Closed joconnor-ecaa closed 8 months ago

joconnor-ecaa commented 9 months ago

Checklist

Reproducible Example

    def test_search_pagination(self):
        PAGE_LIMIT = 5
        items1 = Asset.search(alias="Rooppur nuclear power plant", limit=PAGE_LIMIT, page=0)
        assert len(items1) == PAGE_LIMIT
        items2 = Asset.search(alias="Rooppur nuclear power plant", limit=PAGE_LIMIT, page=1)
        assert len(items2) == PAGE_LIMIT

        ids1 = {item.id for item in items1}
        ids2 = {item.id for item in items2}
        # assert that items on different pages are all different
        assert ids1.intersection(ids2) == set()

Issue Description

Pages 0 and 1 of a search for Assets via the aliases endpoint are not disjoint. In the example above, we see the ID PWRURNRUSA10U3z in both sets.

This may lead to surprising behaviour e.g. when generating dataframes from results.

Expected Behavior

items in page 0 and page 1 should be disjoint (I assume).

apfitzmaurice commented 8 months ago

Resolved by secondary sorting via ID implemented in backend.