Skip to content

Commit

Permalink
Add paging info in search API
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed Feb 16, 2021
1 parent 041c971 commit 4d564b0
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ object SearchApi {
implicit val formatReleaseOptions: OFormat[ReleaseOptions] =
Json.format[ReleaseOptions]

implicit val formatResult: OFormat[Result] =
Json.format[Result]

case class Result(currentPage: Int, pageTotal: Int, items: Seq[Project])
case class Project(
organization: String,
repository: String,
Expand Down Expand Up @@ -164,7 +168,13 @@ class SearchApi(
searchParams(user) { params =>
val result = dataRepository
.findProjects(params)
.map(page => page.items.map(convertProject(params.cli)))
.map { page =>
SearchApi.Result(
currentPage = page.pagination.current,
pageTotal = page.pagination.pageCount,
items = page.items.map(convertProject(params.cli))
)
}
complete(result)
}
}
Expand Down

0 comments on commit 4d564b0

Please sign in to comment.