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:
parent
dfb96c0913
commit
de5dbcaa05
@ -93,7 +93,7 @@ export function getSearchQuery(
|
|||||||
'service.attributes.additionalInformation.tags'
|
'service.attributes.additionalInformation.tags'
|
||||||
]
|
]
|
||||||
return {
|
return {
|
||||||
from: (Number(page) || 0) * (Number(offset) || 21),
|
from: (Number(page) - 1 || 0) * (Number(offset) || 21),
|
||||||
size: Number(offset) || 21,
|
size: Number(offset) || 21,
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
|
@ -63,8 +63,11 @@ export function transformQueryResult(
|
|||||||
(hit: any) => new DDO(hit._source as DDO)
|
(hit: any) => new DDO(hit._source as DDO)
|
||||||
)
|
)
|
||||||
result.totalResults = queryResult.hits.total
|
result.totalResults = queryResult.hits.total
|
||||||
result.totalPages = Math.floor(result.totalResults / size)
|
result.totalPages =
|
||||||
result.page = from ? from / size : 1
|
result.totalResults / size < 1
|
||||||
|
? Math.floor(result.totalResults / size)
|
||||||
|
: Math.ceil(result.totalResults / size)
|
||||||
|
result.page = from ? from / size + 1 : 1
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -89,7 +92,6 @@ export async function queryMetadata(
|
|||||||
{ cancelToken }
|
{ cancelToken }
|
||||||
)
|
)
|
||||||
if (!response || response.status !== 200 || !response.data) return
|
if (!response || response.status !== 200 || !response.data) return
|
||||||
|
|
||||||
return transformQueryResult(response.data, query.from, query.size)
|
return transformQueryResult(response.data, query.from, query.size)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isCancel(error)) {
|
if (axios.isCancel(error)) {
|
||||||
@ -239,7 +241,7 @@ export async function getPublishedAssets(
|
|||||||
accesType = accesType || 'access OR compute'
|
accesType = accesType || 'access OR compute'
|
||||||
|
|
||||||
const queryPublishedAssets = {
|
const queryPublishedAssets = {
|
||||||
from: (Number(page) || 0) * (Number(9) || 21),
|
from: (Number(page) - 1 || 0) * (Number(9) || 21),
|
||||||
size: Number(9) || 21,
|
size: Number(9) || 21,
|
||||||
query: {
|
query: {
|
||||||
query_string: {
|
query_string: {
|
||||||
|
Loading…
Reference in New Issue
Block a user