mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Adapt aquarius queries (#986)
* get aquariusv4 assets * subgraph url fix * make asset details work as much as possible * sort and size fix, comments deleted * get published assets * search wip * page change fix Co-authored-by: ClaudiaHolhos <claudia@oceanprotocol.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
parent
2e794f51a8
commit
8838ae533e
@ -111,7 +111,8 @@ function AssetProvider({
|
||||
setDDO(ddo)
|
||||
setTitle(ddo.metadata.name)
|
||||
setOwner(ddo.nft.owner)
|
||||
setIsInPurgatory(ddo.purgatory.state === true)
|
||||
// TODO: restore asset purgatory once Aquarius supports it, ref #953
|
||||
// setIsInPurgatory(ddo.purgatory.state === true)
|
||||
await setPurgatory(ddo.id)
|
||||
}
|
||||
init()
|
||||
|
@ -4,7 +4,7 @@ export enum SortDirectionOptions {
|
||||
}
|
||||
|
||||
export enum SortTermOptions {
|
||||
Created = 'created',
|
||||
Created = 'metadata.created',
|
||||
Relevance = '_score'
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ export function generateBaseQuery(
|
||||
getFilterTerm('_index', 'aquarius'),
|
||||
...(baseQueryParams.ignorePurgatory
|
||||
? []
|
||||
: [getFilterTerm('isInPurgatory', 'false')])
|
||||
: [getFilterTerm('stats.isInPurgatory', 'false')])
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,7 @@ export async function queryMetadata(
|
||||
): Promise<PagedAssets> {
|
||||
try {
|
||||
const response: AxiosResponse<SearchResponse> = await axios.post(
|
||||
`${metadataCacheUri}/api/v1/aquarius/assets/query`,
|
||||
`${metadataCacheUri}/api/aquarius/assets/query`,
|
||||
{ ...query },
|
||||
{ cancelToken }
|
||||
)
|
||||
@ -116,7 +116,7 @@ export async function retrieveDDO(
|
||||
): Promise<Asset> {
|
||||
try {
|
||||
const response: AxiosResponse<Asset> = await axios.get(
|
||||
`${metadataCacheUri}/api/v1/aquarius/assets/ddo/${did}`,
|
||||
`${metadataCacheUri}/api/aquarius/assets/ddo/${did}`,
|
||||
{ cancelToken }
|
||||
)
|
||||
if (!response || response.status !== 200 || !response.data) return
|
||||
@ -138,7 +138,7 @@ export async function getAssetsNames(
|
||||
): Promise<Record<string, string>> {
|
||||
try {
|
||||
const response: AxiosResponse<Record<string, string>> = await axios.post(
|
||||
`${metadataCacheUri}/api/v1/aquarius/assets/names`,
|
||||
`${metadataCacheUri}/api/aquarius/assets/names`,
|
||||
{ didList },
|
||||
{ cancelToken }
|
||||
)
|
||||
@ -297,11 +297,10 @@ export async function getPublishedAssets(
|
||||
|
||||
const filters: FilterTerm[] = []
|
||||
|
||||
filters.push(getFilterTerm('publicKey.owner', accountId.toLowerCase()))
|
||||
filters.push(getFilterTerm('nft.owner', accountId.toLowerCase()))
|
||||
accesType !== undefined &&
|
||||
filters.push(getFilterTerm('service.type', accesType))
|
||||
type !== undefined &&
|
||||
filters.push(getFilterTerm('service.attributes.main.type', type))
|
||||
filters.push(getFilterTerm('services.type', accesType))
|
||||
type !== undefined && filters.push(getFilterTerm('metadata.type', type))
|
||||
|
||||
const baseQueryParams = {
|
||||
chainIds,
|
||||
|
@ -26,7 +26,7 @@ export default function AssetActions({
|
||||
}): ReactElement {
|
||||
const { accountId, balance } = useWeb3()
|
||||
const { isAssetNetwork } = useAsset()
|
||||
const { values } = useFormikContext<FormPublishData>()
|
||||
const formikState = useFormikContext<FormPublishData>()
|
||||
|
||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>()
|
||||
const [dtBalance, setDtBalance] = useState<string>()
|
||||
@ -64,9 +64,10 @@ export default function AssetActions({
|
||||
async function initFileInfo() {
|
||||
setFileIsLoading(true)
|
||||
|
||||
const asset = values?.services?.[0].files?.[0].url || ddo.id
|
||||
const asset = formikState?.values?.services?.[0].files?.[0].url || ddo.id
|
||||
const providerUrl =
|
||||
values?.services[0].providerUrl.url || oceanConfig.providerUri
|
||||
formikState?.values?.services[0].providerUrl.url ||
|
||||
oceanConfig.providerUri
|
||||
|
||||
try {
|
||||
const fileInfoResponse = await getFileInfo(asset, providerUrl)
|
||||
@ -77,7 +78,7 @@ export default function AssetActions({
|
||||
}
|
||||
}
|
||||
initFileInfo()
|
||||
}, [ddo, isMounted, newCancelToken, values?.services])
|
||||
}, [ddo, isMounted, newCancelToken, formikState?.values?.services])
|
||||
|
||||
// Get and set user DT balance
|
||||
useEffect(() => {
|
||||
|
@ -114,12 +114,13 @@ export default function HomePage(): ReactElement {
|
||||
|
||||
const baseParams = {
|
||||
chainIds: chainIds,
|
||||
esPaginationOptions: { size: 9 },
|
||||
esPaginationOptions: {
|
||||
size: 9
|
||||
},
|
||||
sortOptions: {
|
||||
sortBy: SortTermOptions.Created
|
||||
} as SortOptions
|
||||
} as BaseQueryParams
|
||||
|
||||
setQueryLatest(generateBaseQuery(baseParams))
|
||||
}, [chainIds])
|
||||
|
||||
@ -143,7 +144,10 @@ export default function HomePage(): ReactElement {
|
||||
title="Recently Published"
|
||||
query={queryLatest}
|
||||
action={
|
||||
<Button style="text" to="/search?sort=created&sortOrder=desc">
|
||||
<Button
|
||||
style="text"
|
||||
to="/search?sort=metadata.created&sortOrder=desc"
|
||||
>
|
||||
All data sets and algorithms →
|
||||
</Button>
|
||||
}
|
||||
|
@ -41,7 +41,12 @@ export default function SearchPage({
|
||||
(page: number) => {
|
||||
const { pathname, query } = router
|
||||
const newUrl = updateQueryStringParameter(
|
||||
pathname + query,
|
||||
pathname +
|
||||
'?' +
|
||||
JSON.stringify(query)
|
||||
.replace(/"|{|}/g, '')
|
||||
.replace(/:/g, '=')
|
||||
.replace(/,/g, '&'),
|
||||
'page',
|
||||
`${page}`
|
||||
)
|
||||
|
@ -47,14 +47,14 @@ export function getSearchQuery(
|
||||
const emptySearchTerm = text === undefined || text === ''
|
||||
|
||||
let searchTerm = owner
|
||||
? `(publicKey.owner:${owner})`
|
||||
? `(nft.owner:${owner})`
|
||||
: tags
|
||||
? // eslint-disable-next-line no-useless-escape
|
||||
`(service.attributes.additionalInformation.tags:\"${tags}\")`
|
||||
: categories
|
||||
? // eslint-disable-next-line no-useless-escape
|
||||
`(service.attributes.additionalInformation.categories:\"${categories}\")`
|
||||
: text || ''
|
||||
`(metadata.tags:\"${tags}\")`
|
||||
: // : categories
|
||||
// ? // eslint-disable-next-line no-useless-escape
|
||||
// `(service.attributes.additionalInformation.categories:\"${categories}\")`
|
||||
text || ''
|
||||
|
||||
searchTerm = searchTerm.trim()
|
||||
const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim()
|
||||
@ -68,14 +68,14 @@ export function getSearchQuery(
|
||||
: '**'
|
||||
const searchFields = [
|
||||
'id',
|
||||
'publicKey.owner',
|
||||
'dataToken',
|
||||
'dataTokenInfo.name',
|
||||
'dataTokenInfo.symbol',
|
||||
'service.attributes.main.name^10',
|
||||
'service.attributes.main.author',
|
||||
'service.attributes.additionalInformation.description',
|
||||
'service.attributes.additionalInformation.tags'
|
||||
'nft.owner',
|
||||
'datatokens.address',
|
||||
'datatokens.name',
|
||||
'datatokens.symbol',
|
||||
'metadata.name^10',
|
||||
'metadata.author',
|
||||
'metadata.description',
|
||||
'metadata.tags'
|
||||
]
|
||||
|
||||
const nestedQuery = {
|
||||
@ -123,9 +123,9 @@ export function getSearchQuery(
|
||||
|
||||
const filters: FilterTerm[] = []
|
||||
accessType !== undefined &&
|
||||
filters.push(getFilterTerm('service.type', accessType))
|
||||
filters.push(getFilterTerm('nft.type', accessType))
|
||||
serviceType !== undefined &&
|
||||
filters.push(getFilterTerm('service.attributes.main.type', serviceType))
|
||||
filters.push(getFilterTerm('metadata.type', serviceType))
|
||||
|
||||
const baseQueryParams = {
|
||||
chainIds,
|
||||
@ -139,7 +139,6 @@ export function getSearchQuery(
|
||||
} as BaseQueryParams
|
||||
|
||||
const query = generateBaseQuery(baseQueryParams)
|
||||
|
||||
return query
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user