mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
compute jobs refetch and reuse order
This commit is contained in:
parent
9ffa3419a6
commit
565e7bfa31
@ -38,6 +38,13 @@ const tokensPriceQuery = gql`
|
||||
tx
|
||||
serviceIndex
|
||||
createdTimestamp
|
||||
reuses(orderBy: createdTimestamp, orderDirection: desc) {
|
||||
id
|
||||
caller
|
||||
createdTimestamp
|
||||
tx
|
||||
block
|
||||
}
|
||||
}
|
||||
dispensers {
|
||||
id
|
||||
@ -103,6 +110,13 @@ const tokenPriceQuery = gql`
|
||||
tx
|
||||
serviceIndex
|
||||
createdTimestamp
|
||||
reuses(orderBy: createdTimestamp, orderDirection: desc) {
|
||||
id
|
||||
caller
|
||||
createdTimestamp
|
||||
tx
|
||||
block
|
||||
}
|
||||
}
|
||||
dispensers {
|
||||
id
|
||||
@ -157,12 +171,17 @@ function getAccessDetailsFromTokenPrice(
|
||||
timeout?: number
|
||||
): AccessDetails {
|
||||
const accessDetails = {} as AccessDetails
|
||||
|
||||
if (tokenPrice && tokenPrice.orders && tokenPrice.orders.length > 0) {
|
||||
const order = tokenPrice.orders[0]
|
||||
const reusedOrder =
|
||||
order && order.reuses && order.reuses.length > 0 ? order.reuses[0] : null
|
||||
console.log('order', order)
|
||||
console.log('reusedOrder', reusedOrder)
|
||||
// asset is owned if there is an order and asset has timeout 0 (forever) or if the condition is valid
|
||||
accessDetails.isOwned =
|
||||
timeout === 0 || Date.now() / 1000 - order.createdTimestamp < timeout
|
||||
accessDetails.validOrderTx = order.tx
|
||||
accessDetails.validOrderTx = reusedOrder ? reusedOrder.tx : order.tx
|
||||
}
|
||||
|
||||
// TODO: fetch order fee from sub query
|
||||
|
@ -102,6 +102,7 @@ export default function Compute({
|
||||
useState<OrderPriceAndFees>()
|
||||
const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] =
|
||||
useState(false)
|
||||
const [refatchJobs, setRefatchJobs] = useState(false)
|
||||
// const [isProviderFeeValid, setIsProviderFeeValid] = useState(false)
|
||||
const isComputeButtonDisabled =
|
||||
isJobStarting === true ||
|
||||
@ -372,6 +373,8 @@ export default function Compute({
|
||||
}
|
||||
LoggerInstance.log('[compute] Starting compute job response: ', response)
|
||||
setIsPublished(true)
|
||||
console.log('setRefatchJobs true')
|
||||
setRefatchJobs(!refatchJobs)
|
||||
initPriceAndFees()
|
||||
} catch (error) {
|
||||
setError('Failed to start job!')
|
||||
@ -461,7 +464,11 @@ export default function Compute({
|
||||
</footer>
|
||||
{accountId && asset?.accessDetails?.datatoken && (
|
||||
<AssetActionHistoryTable title="Your Compute Jobs">
|
||||
<ComputeJobs minimal assetChainId={[asset?.chainId]} />
|
||||
<ComputeJobs
|
||||
minimal
|
||||
assetChainId={[asset?.chainId]}
|
||||
refatchJobs={refatchJobs}
|
||||
/>
|
||||
</AssetActionHistoryTable>
|
||||
)}
|
||||
</>
|
||||
|
@ -71,10 +71,12 @@ const columns = [
|
||||
|
||||
export default function ComputeJobs({
|
||||
minimal,
|
||||
assetChainId
|
||||
assetChainId,
|
||||
refatchJobs
|
||||
}: {
|
||||
minimal?: boolean
|
||||
assetChainId?: number[]
|
||||
refatchJobs?: boolean
|
||||
}): ReactElement {
|
||||
const { accountId } = useWeb3()
|
||||
const { asset } = useAsset()
|
||||
@ -110,6 +112,11 @@ export default function ComputeJobs({
|
||||
fetchJobs()
|
||||
}, [fetchJobs])
|
||||
|
||||
useEffect(() => {
|
||||
console.log('use effect ', refatchJobs)
|
||||
fetchJobs()
|
||||
}, [refatchJobs])
|
||||
|
||||
return accountId ? (
|
||||
<>
|
||||
{jobs?.length >= 0 && !minimal && (
|
||||
|
Loading…
Reference in New Issue
Block a user