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)
|
setDDO(ddo)
|
||||||
setTitle(ddo.metadata.name)
|
setTitle(ddo.metadata.name)
|
||||||
setOwner(ddo.nft.owner)
|
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)
|
await setPurgatory(ddo.id)
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
|
@ -4,7 +4,7 @@ export enum SortDirectionOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum SortTermOptions {
|
export enum SortTermOptions {
|
||||||
Created = 'created',
|
Created = 'metadata.created',
|
||||||
Relevance = '_score'
|
Relevance = '_score'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export function generateBaseQuery(
|
|||||||
getFilterTerm('_index', 'aquarius'),
|
getFilterTerm('_index', 'aquarius'),
|
||||||
...(baseQueryParams.ignorePurgatory
|
...(baseQueryParams.ignorePurgatory
|
||||||
? []
|
? []
|
||||||
: [getFilterTerm('isInPurgatory', 'false')])
|
: [getFilterTerm('stats.isInPurgatory', 'false')])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ export async function queryMetadata(
|
|||||||
): Promise<PagedAssets> {
|
): Promise<PagedAssets> {
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse<SearchResponse> = await axios.post(
|
const response: AxiosResponse<SearchResponse> = await axios.post(
|
||||||
`${metadataCacheUri}/api/v1/aquarius/assets/query`,
|
`${metadataCacheUri}/api/aquarius/assets/query`,
|
||||||
{ ...query },
|
{ ...query },
|
||||||
{ cancelToken }
|
{ cancelToken }
|
||||||
)
|
)
|
||||||
@ -116,7 +116,7 @@ export async function retrieveDDO(
|
|||||||
): Promise<Asset> {
|
): Promise<Asset> {
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse<Asset> = await axios.get(
|
const response: AxiosResponse<Asset> = await axios.get(
|
||||||
`${metadataCacheUri}/api/v1/aquarius/assets/ddo/${did}`,
|
`${metadataCacheUri}/api/aquarius/assets/ddo/${did}`,
|
||||||
{ cancelToken }
|
{ cancelToken }
|
||||||
)
|
)
|
||||||
if (!response || response.status !== 200 || !response.data) return
|
if (!response || response.status !== 200 || !response.data) return
|
||||||
@ -138,7 +138,7 @@ export async function getAssetsNames(
|
|||||||
): Promise<Record<string, string>> {
|
): Promise<Record<string, string>> {
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse<Record<string, string>> = await axios.post(
|
const response: AxiosResponse<Record<string, string>> = await axios.post(
|
||||||
`${metadataCacheUri}/api/v1/aquarius/assets/names`,
|
`${metadataCacheUri}/api/aquarius/assets/names`,
|
||||||
{ didList },
|
{ didList },
|
||||||
{ cancelToken }
|
{ cancelToken }
|
||||||
)
|
)
|
||||||
@ -297,11 +297,10 @@ export async function getPublishedAssets(
|
|||||||
|
|
||||||
const filters: FilterTerm[] = []
|
const filters: FilterTerm[] = []
|
||||||
|
|
||||||
filters.push(getFilterTerm('publicKey.owner', accountId.toLowerCase()))
|
filters.push(getFilterTerm('nft.owner', accountId.toLowerCase()))
|
||||||
accesType !== undefined &&
|
accesType !== undefined &&
|
||||||
filters.push(getFilterTerm('service.type', accesType))
|
filters.push(getFilterTerm('services.type', accesType))
|
||||||
type !== undefined &&
|
type !== undefined && filters.push(getFilterTerm('metadata.type', type))
|
||||||
filters.push(getFilterTerm('service.attributes.main.type', type))
|
|
||||||
|
|
||||||
const baseQueryParams = {
|
const baseQueryParams = {
|
||||||
chainIds,
|
chainIds,
|
||||||
|
@ -26,7 +26,7 @@ export default function AssetActions({
|
|||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { accountId, balance } = useWeb3()
|
const { accountId, balance } = useWeb3()
|
||||||
const { isAssetNetwork } = useAsset()
|
const { isAssetNetwork } = useAsset()
|
||||||
const { values } = useFormikContext<FormPublishData>()
|
const formikState = useFormikContext<FormPublishData>()
|
||||||
|
|
||||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>()
|
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>()
|
||||||
const [dtBalance, setDtBalance] = useState<string>()
|
const [dtBalance, setDtBalance] = useState<string>()
|
||||||
@ -64,9 +64,10 @@ export default function AssetActions({
|
|||||||
async function initFileInfo() {
|
async function initFileInfo() {
|
||||||
setFileIsLoading(true)
|
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 =
|
const providerUrl =
|
||||||
values?.services[0].providerUrl.url || oceanConfig.providerUri
|
formikState?.values?.services[0].providerUrl.url ||
|
||||||
|
oceanConfig.providerUri
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fileInfoResponse = await getFileInfo(asset, providerUrl)
|
const fileInfoResponse = await getFileInfo(asset, providerUrl)
|
||||||
@ -77,7 +78,7 @@ export default function AssetActions({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
initFileInfo()
|
initFileInfo()
|
||||||
}, [ddo, isMounted, newCancelToken, values?.services])
|
}, [ddo, isMounted, newCancelToken, formikState?.values?.services])
|
||||||
|
|
||||||
// Get and set user DT balance
|
// Get and set user DT balance
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -114,12 +114,13 @@ export default function HomePage(): ReactElement {
|
|||||||
|
|
||||||
const baseParams = {
|
const baseParams = {
|
||||||
chainIds: chainIds,
|
chainIds: chainIds,
|
||||||
esPaginationOptions: { size: 9 },
|
esPaginationOptions: {
|
||||||
|
size: 9
|
||||||
|
},
|
||||||
sortOptions: {
|
sortOptions: {
|
||||||
sortBy: SortTermOptions.Created
|
sortBy: SortTermOptions.Created
|
||||||
} as SortOptions
|
} as SortOptions
|
||||||
} as BaseQueryParams
|
} as BaseQueryParams
|
||||||
|
|
||||||
setQueryLatest(generateBaseQuery(baseParams))
|
setQueryLatest(generateBaseQuery(baseParams))
|
||||||
}, [chainIds])
|
}, [chainIds])
|
||||||
|
|
||||||
@ -143,7 +144,10 @@ export default function HomePage(): ReactElement {
|
|||||||
title="Recently Published"
|
title="Recently Published"
|
||||||
query={queryLatest}
|
query={queryLatest}
|
||||||
action={
|
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 →
|
All data sets and algorithms →
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,12 @@ export default function SearchPage({
|
|||||||
(page: number) => {
|
(page: number) => {
|
||||||
const { pathname, query } = router
|
const { pathname, query } = router
|
||||||
const newUrl = updateQueryStringParameter(
|
const newUrl = updateQueryStringParameter(
|
||||||
pathname + query,
|
pathname +
|
||||||
|
'?' +
|
||||||
|
JSON.stringify(query)
|
||||||
|
.replace(/"|{|}/g, '')
|
||||||
|
.replace(/:/g, '=')
|
||||||
|
.replace(/,/g, '&'),
|
||||||
'page',
|
'page',
|
||||||
`${page}`
|
`${page}`
|
||||||
)
|
)
|
||||||
|
@ -47,14 +47,14 @@ export function getSearchQuery(
|
|||||||
const emptySearchTerm = text === undefined || text === ''
|
const emptySearchTerm = text === undefined || text === ''
|
||||||
|
|
||||||
let searchTerm = owner
|
let searchTerm = owner
|
||||||
? `(publicKey.owner:${owner})`
|
? `(nft.owner:${owner})`
|
||||||
: tags
|
: tags
|
||||||
? // eslint-disable-next-line no-useless-escape
|
? // eslint-disable-next-line no-useless-escape
|
||||||
`(service.attributes.additionalInformation.tags:\"${tags}\")`
|
`(metadata.tags:\"${tags}\")`
|
||||||
: categories
|
: // : categories
|
||||||
? // eslint-disable-next-line no-useless-escape
|
// ? // eslint-disable-next-line no-useless-escape
|
||||||
`(service.attributes.additionalInformation.categories:\"${categories}\")`
|
// `(service.attributes.additionalInformation.categories:\"${categories}\")`
|
||||||
: text || ''
|
text || ''
|
||||||
|
|
||||||
searchTerm = searchTerm.trim()
|
searchTerm = searchTerm.trim()
|
||||||
const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim()
|
const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim()
|
||||||
@ -68,14 +68,14 @@ export function getSearchQuery(
|
|||||||
: '**'
|
: '**'
|
||||||
const searchFields = [
|
const searchFields = [
|
||||||
'id',
|
'id',
|
||||||
'publicKey.owner',
|
'nft.owner',
|
||||||
'dataToken',
|
'datatokens.address',
|
||||||
'dataTokenInfo.name',
|
'datatokens.name',
|
||||||
'dataTokenInfo.symbol',
|
'datatokens.symbol',
|
||||||
'service.attributes.main.name^10',
|
'metadata.name^10',
|
||||||
'service.attributes.main.author',
|
'metadata.author',
|
||||||
'service.attributes.additionalInformation.description',
|
'metadata.description',
|
||||||
'service.attributes.additionalInformation.tags'
|
'metadata.tags'
|
||||||
]
|
]
|
||||||
|
|
||||||
const nestedQuery = {
|
const nestedQuery = {
|
||||||
@ -123,9 +123,9 @@ export function getSearchQuery(
|
|||||||
|
|
||||||
const filters: FilterTerm[] = []
|
const filters: FilterTerm[] = []
|
||||||
accessType !== undefined &&
|
accessType !== undefined &&
|
||||||
filters.push(getFilterTerm('service.type', accessType))
|
filters.push(getFilterTerm('nft.type', accessType))
|
||||||
serviceType !== undefined &&
|
serviceType !== undefined &&
|
||||||
filters.push(getFilterTerm('service.attributes.main.type', serviceType))
|
filters.push(getFilterTerm('metadata.type', serviceType))
|
||||||
|
|
||||||
const baseQueryParams = {
|
const baseQueryParams = {
|
||||||
chainIds,
|
chainIds,
|
||||||
@ -139,7 +139,6 @@ export function getSearchQuery(
|
|||||||
} as BaseQueryParams
|
} as BaseQueryParams
|
||||||
|
|
||||||
const query = generateBaseQuery(baseQueryParams)
|
const query = generateBaseQuery(baseQueryParams)
|
||||||
|
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user