Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQSERVICES-1773] Allow pagination for team search endpoints - has_more #2898

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelog.d/2-features/pr-2895
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Team search endpoint now supports pagination
Team search endpoint now supports pagination (#2898, #2895)
4 changes: 3 additions & 1 deletion libs/wire-api/src/Wire/API/Routes/Public/Brig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,9 @@ type SearchAPI =
:> QueryParam'
[ Optional,
Strict,
Description "Paging state for the next page of results"
Description
"Optional, when not specified, the first page will be returned. \
\Every returned page contains a `paging_state`, this should be supplied to retrieve the next page."
]
"pagingState"
PagingState
Expand Down
6 changes: 4 additions & 2 deletions libs/wire-api/src/Wire/API/User/Search.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ data SearchResult a = SearchResult
searchTook :: Int,
searchResults :: [a],
searchPolicy :: FederatedUserSearchPolicy,
searchPagingState :: Maybe PagingState
searchPagingState :: Maybe PagingState,
searchHasMore :: Maybe Bool
}
deriving stock (Eq, Show, Generic, Functor)
deriving (Arbitrary) via (GenericUniform (SearchResult a))
Expand All @@ -121,7 +122,8 @@ instance ToSchema a => ToSchema (SearchResult a) where
<*> searchTook .= fieldWithDocModifier "took" (S.description ?~ "Search time in ms") schema
<*> searchResults .= fieldWithDocModifier "documents" (S.description ?~ "List of contacts found") (array schema)
<*> searchPolicy .= fieldWithDocModifier "search_policy" (S.description ?~ "Search policy that was applied when searching for users") schema
<*> searchPagingState .= maybe_ (optFieldWithDocModifier "paging_state" (S.description ?~ "Paging state for the next page of results") schema)
<*> searchPagingState .= maybe_ (optFieldWithDocModifier "paging_state" (S.description ?~ "Paging state that should be supplied to retrieve the next page of results") schema)
<*> searchHasMore .= maybe_ (optFieldWithDocModifier "has_more" (S.description ?~ "Indicates whether there are more results to be fetched") schema)

deriving via (Schema (SearchResult Contact)) instance ToJSON (SearchResult Contact)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Data.Domain (Domain (Domain, _domainText))
import Data.Id (Id (Id))
import Data.Qualified (Qualified (Qualified, qDomain, qUnqualified))
import qualified Data.UUID as UUID (fromString)
import Imports (Maybe (Just, Nothing), fromJust)
import Imports (Bool (..), Maybe (Just, Nothing), fromJust)
import Wire.API.User.Search (Contact (..), FederatedUserSearchPolicy (ExactHandleSearch, FullSearch), PagingState (..), SearchResult (..))

testObject_SearchResult_20Contact_user_1 :: SearchResult Contact
Expand All @@ -34,7 +34,8 @@ testObject_SearchResult_20Contact_user_1 =
searchTook = 1,
searchResults = [],
searchPolicy = FullSearch,
searchPagingState = Just (PagingState "WzE2Njk5OTQ5MzIyNjdd")
searchPagingState = Just (PagingState "WzE2Njk5OTQ5MzIyNjdd"),
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_2 :: SearchResult Contact
Expand All @@ -45,7 +46,8 @@ testObject_SearchResult_20Contact_user_2 =
searchTook = -5,
searchResults = [],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Just True
}

testObject_SearchResult_20Contact_user_3 :: SearchResult Contact
Expand All @@ -68,7 +70,8 @@ testObject_SearchResult_20Contact_user_3 =
}
],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Just False
}

testObject_SearchResult_20Contact_user_4 :: SearchResult Contact
Expand Down Expand Up @@ -146,7 +149,8 @@ testObject_SearchResult_20Contact_user_4 =
}
],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_5 :: SearchResult Contact
Expand All @@ -169,7 +173,8 @@ testObject_SearchResult_20Contact_user_5 =
}
],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_6 :: SearchResult Contact
Expand All @@ -180,7 +185,8 @@ testObject_SearchResult_20Contact_user_6 =
searchTook = 5,
searchResults = [],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_7 :: SearchResult Contact
Expand Down Expand Up @@ -214,7 +220,8 @@ testObject_SearchResult_20Contact_user_7 =
}
],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_8 :: SearchResult Contact
Expand All @@ -237,7 +244,8 @@ testObject_SearchResult_20Contact_user_8 =
}
],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_9 :: SearchResult Contact
Expand All @@ -248,7 +256,8 @@ testObject_SearchResult_20Contact_user_9 =
searchTook = 3,
searchResults = [],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_10 :: SearchResult Contact
Expand All @@ -259,7 +268,8 @@ testObject_SearchResult_20Contact_user_10 =
searchTook = -5,
searchResults = [],
searchPolicy = FullSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_11 :: SearchResult Contact
Expand Down Expand Up @@ -293,7 +303,8 @@ testObject_SearchResult_20Contact_user_11 =
}
],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_12 :: SearchResult Contact
Expand All @@ -304,7 +315,8 @@ testObject_SearchResult_20Contact_user_12 =
searchTook = 3,
searchResults = [],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_13 :: SearchResult Contact
Expand Down Expand Up @@ -360,7 +372,8 @@ testObject_SearchResult_20Contact_user_13 =
}
],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_14 :: SearchResult Contact
Expand Down Expand Up @@ -394,7 +407,8 @@ testObject_SearchResult_20Contact_user_14 =
}
],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_15 :: SearchResult Contact
Expand All @@ -405,7 +419,8 @@ testObject_SearchResult_20Contact_user_15 =
searchTook = 4,
searchResults = [],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_16 :: SearchResult Contact
Expand All @@ -416,7 +431,8 @@ testObject_SearchResult_20Contact_user_16 =
searchTook = -7,
searchResults = [],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_17 :: SearchResult Contact
Expand All @@ -427,7 +443,8 @@ testObject_SearchResult_20Contact_user_17 =
searchTook = -1,
searchResults = [],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_18 :: SearchResult Contact
Expand All @@ -438,7 +455,8 @@ testObject_SearchResult_20Contact_user_18 =
searchTook = -5,
searchResults = [],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_19 :: SearchResult Contact
Expand Down Expand Up @@ -472,7 +490,8 @@ testObject_SearchResult_20Contact_user_19 =
}
],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}

testObject_SearchResult_20Contact_user_20 :: SearchResult Contact
Expand Down Expand Up @@ -627,5 +646,6 @@ testObject_SearchResult_20Contact_user_20 =
}
],
searchPolicy = ExactHandleSearch,
searchPagingState = Nothing
searchPagingState = Nothing,
searchHasMore = Nothing
}
Loading