1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Fix published assets (#878)

* fix page

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* fix page search

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* use component state for page on pagination instead of the returned page

* fix returned page

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* put back queryResult.page

* Update src/utils/aquarius.ts

Co-authored-by: Bogdan Fazakas <bogdan.fazakas@gmail.com>

* lint

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

Co-authored-by: Bogdan Fazakas <bogdan.fazakas@gmail.com>
This commit is contained in:
mihaisc 2021-09-27 15:43:12 +03:00 committed by GitHub
parent dfb96c0913
commit de5dbcaa05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -93,7 +93,7 @@ export function getSearchQuery(
'service.attributes.additionalInformation.tags'
]
return {
from: (Number(page) || 0) * (Number(offset) || 21),
from: (Number(page) - 1 || 0) * (Number(offset) || 21),
size: Number(offset) || 21,
query: {
bool: {

View File

@ -63,8 +63,11 @@ export function transformQueryResult(
(hit: any) => new DDO(hit._source as DDO)
)
result.totalResults = queryResult.hits.total
result.totalPages = Math.floor(result.totalResults / size)
result.page = from ? from / size : 1
result.totalPages =
result.totalResults / size < 1
? Math.floor(result.totalResults / size)
: Math.ceil(result.totalResults / size)
result.page = from ? from / size + 1 : 1
return result
}
@ -89,7 +92,6 @@ export async function queryMetadata(
{ cancelToken }
)
if (!response || response.status !== 200 || !response.data) return
return transformQueryResult(response.data, query.from, query.size)
} catch (error) {
if (axios.isCancel(error)) {
@ -239,7 +241,7 @@ export async function getPublishedAssets(
accesType = accesType || 'access OR compute'
const queryPublishedAssets = {
from: (Number(page) || 0) * (Number(9) || 21),
from: (Number(page) - 1 || 0) * (Number(9) || 21),
size: Number(9) || 21,
query: {
query_string: {