From 1599d74cfed5ea90e397ed3de4474787efe36ae4 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Thu, 18 Mar 2021 13:27:58 +0200 Subject: [PATCH] Update search and publish (#444) * fix querys Signed-off-by: mihaisc * lib bump, publish update Signed-off-by: mihaisc * package-lock Signed-off-by: mihaisc * fix searchquery Signed-off-by: mihaisc --- README.md | 1 - package-lock.json | 8 ++++---- package.json | 2 +- src/components/molecules/Bookmarks.tsx | 3 +-- src/components/pages/History/PublishedList.tsx | 3 +-- src/components/pages/Home.tsx | 12 ++++++------ src/components/templates/Search/utils.ts | 3 +-- src/hooks/usePublish.ts | 2 ++ 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index ff4e7c067..331a58ad4 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,6 @@ const queryLatest = { page: 1, offset: 9, query: { - nativeSearch: 1, // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html query_string: { query: `-isInPurgatory:true` } }, diff --git a/package-lock.json b/package-lock.json index fa9e8a170..5c5156dda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3625,9 +3625,9 @@ "integrity": "sha512-6GrBk1jy+zxjDjh2SPra06etrqdp8CB6RaZaTq2OQpK8dA2Dq91hqCbj+6eb21MlU8bDY3/atnxax9rgPgsxkA==" }, "@oceanprotocol/lib": { - "version": "0.11.4", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.11.4.tgz", - "integrity": "sha512-sYfbgsOmiF6RrSjeGCvKEXoLl2Q41wKuoWT5gAqy7IoyVjwDerx96kLdTZp33etMoQ0/MJRud0ZGL0sZwqfVWw==", + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.12.0.tgz", + "integrity": "sha512-bREJhiyQ1LlFdLY0WoZbelfH27R7PLi0pY+c3TiX3fYvDShfp5NCYkq0B8Wf4FjxUxd4BMJREwRNdOS416RYVA==", "requires": { "@ethereum-navigator/navigator": "^0.5.2", "@oceanprotocol/contracts": "^0.5.10", @@ -16410,7 +16410,7 @@ } }, "ethereumjs-abi": { - "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#1a27c59c15ab1e95ee8e5c4ed6ad814c49cc439e", + "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#1ce6a1d64235fabe2aaf827fd606def55693508f", "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git", "requires": { "bn.js": "^4.11.8", diff --git a/package.json b/package.json index ef7a74395..5c5c9e804 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@coingecko/cryptoformat": "^0.4.2", "@loadable/component": "^5.14.1", "@oceanprotocol/art": "^3.0.0", - "@oceanprotocol/lib": "^0.11.4", + "@oceanprotocol/lib": "^0.12.0", "@oceanprotocol/typographies": "^0.1.0", "@portis/web3": "^3.0.3", "@sindresorhus/slugify": "^1.0.0", diff --git a/src/components/molecules/Bookmarks.tsx b/src/components/molecules/Bookmarks.tsx index f991b643c..d2a18e7ee 100644 --- a/src/components/molecules/Bookmarks.tsx +++ b/src/components/molecules/Bookmarks.tsx @@ -26,7 +26,6 @@ async function getAssetsBookmarked( page: 1, offset: 100, query: { - nativeSearch: 1, query_string: { query: searchDids, fields: ['dataToken'], @@ -34,7 +33,7 @@ async function getAssetsBookmarked( } }, sort: { created: -1 } - } as any + } try { const result = await queryMetadata( diff --git a/src/components/pages/History/PublishedList.tsx b/src/components/pages/History/PublishedList.tsx index e62a4700b..033fe33f3 100644 --- a/src/components/pages/History/PublishedList.tsx +++ b/src/components/pages/History/PublishedList.tsx @@ -25,7 +25,6 @@ export default function PublishedList(): ReactElement { page: page, offset: 9, query: { - nativeSearch: 1, query_string: { query: `(publicKey.owner:${accountId})` } @@ -35,7 +34,7 @@ export default function PublishedList(): ReactElement { try { queryResult || setIsLoading(true) const result = await queryMetadata( - queryPublishedAssets as any, + queryPublishedAssets, config.metadataCacheUri, source.token ) diff --git a/src/components/pages/Home.tsx b/src/components/pages/Home.tsx index 41ea062f6..d34d0369f 100644 --- a/src/components/pages/Home.tsx +++ b/src/components/pages/Home.tsx @@ -2,7 +2,10 @@ import React, { ReactElement, useEffect, useState } from 'react' import SearchBar from '../molecules/SearchBar' import styles from './Home.module.css' import AssetList from '../organisms/AssetList' -import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache' +import { + QueryResult, + SearchQuery +} from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache' import Container from '../atoms/Container' import Loader from '../atoms/Loader' import { useOcean } from '../../providers/Ocean' @@ -15,7 +18,6 @@ const queryHighest = { page: 1, offset: 9, query: { - nativeSearch: 1, query_string: { query: `(price.type:pool) -isInPurgatory:true` } @@ -27,7 +29,6 @@ const queryLatest = { page: 1, offset: 9, query: { - nativeSearch: 1, query_string: { query: `-isInPurgatory:true` } @@ -49,7 +50,7 @@ function SectionQueryResult({ action }: { title: ReactElement | string - query: any + query: SearchQuery action?: ReactElement }) { const { config } = useOcean() @@ -62,9 +63,8 @@ function SectionQueryResult({ const source = axios.CancelToken.source() async function init() { - // TODO: remove any once ocean.js has nativeSearch typings const result = await queryMetadata( - query as any, + query, config.metadataCacheUri, source.token ) diff --git a/src/components/templates/Search/utils.ts b/src/components/templates/Search/utils.ts index 641b7189a..0d15339fd 100644 --- a/src/components/templates/Search/utils.ts +++ b/src/components/templates/Search/utils.ts @@ -78,7 +78,6 @@ export function getSearchQuery( page: Number(page) || 1, offset: Number(offset) || 21, query: { - nativeSearch: 1, query_string: { query: `${searchTerm} -isInPurgatory:true` } @@ -98,7 +97,7 @@ export function getSearchQuery( // And the next hack, // nativeSearch is not implmeneted on ocean.js typings - } as any + } } export async function getResults( diff --git a/src/hooks/usePublish.ts b/src/hooks/usePublish.ts index 3d556ea7c..6ef5cbda8 100644 --- a/src/hooks/usePublish.ts +++ b/src/hooks/usePublish.ts @@ -145,6 +145,8 @@ function usePublish(): UsePublish { providerUri ) .next(setStep) + + await ocean.assets.publishDdo(ddo, account.getId()) Logger.log('ddo created', ddo) await sleep(20000) setStep(7)