mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix compute jobs section and your jobs
This commit is contained in:
parent
70f181a595
commit
9171db8b6e
@ -213,21 +213,14 @@ async function getJobs(
|
|||||||
accountId: string,
|
accountId: string,
|
||||||
assets: Asset[]
|
assets: Asset[]
|
||||||
): Promise<ComputeJobMetaData[]> {
|
): Promise<ComputeJobMetaData[]> {
|
||||||
console.log('compute.ts getJobs providerUrls:', providerUrls)
|
|
||||||
const computeJobs: ComputeJobMetaData[] = []
|
const computeJobs: ComputeJobMetaData[] = []
|
||||||
console.log('compute.ts getJobs assets:', providerUrls)
|
for await (const providerUrl of providerUrls) {
|
||||||
providerUrls.forEach(async (providerUrl) => {
|
|
||||||
try {
|
try {
|
||||||
const providerComputeJobs = (await ProviderInstance.computeStatus(
|
const providerComputeJobs = (await ProviderInstance.computeStatus(
|
||||||
providerUrl,
|
providerUrl,
|
||||||
accountId
|
accountId
|
||||||
)) as ComputeJob[]
|
)) as ComputeJob[]
|
||||||
|
|
||||||
console.log(
|
|
||||||
'compute.ts getJobs providerComputeJobs:',
|
|
||||||
providerComputeJobs
|
|
||||||
)
|
|
||||||
|
|
||||||
if (providerComputeJobs) {
|
if (providerComputeJobs) {
|
||||||
providerComputeJobs.sort((a, b) => {
|
providerComputeJobs.sort((a, b) => {
|
||||||
if (a.dateCreated > b.dateCreated) {
|
if (a.dateCreated > b.dateCreated) {
|
||||||
@ -239,18 +232,10 @@ async function getJobs(
|
|||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
|
||||||
'compute.ts getJobs providerComputeJobs sorted:',
|
|
||||||
providerComputeJobs
|
|
||||||
)
|
|
||||||
|
|
||||||
providerComputeJobs.forEach((job) => {
|
providerComputeJobs.forEach((job) => {
|
||||||
const did = job.inputDID[0]
|
const did = job.inputDID[0]
|
||||||
const asset = assets.filter((x) => x.id === did)[0]
|
const asset = assets.filter((x) => x.id === did)[0]
|
||||||
|
if (asset) {
|
||||||
console.log('compute.ts getJobs did:', providerComputeJobs)
|
|
||||||
console.log('compute.ts getJobs asset:', asset)
|
|
||||||
if (!asset) {
|
|
||||||
const compJob: ComputeJobMetaData = {
|
const compJob: ComputeJobMetaData = {
|
||||||
...job,
|
...job,
|
||||||
assetName: asset.metadata.name,
|
assetName: asset.metadata.name,
|
||||||
@ -262,10 +247,9 @@ async function getJobs(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('compute.ts getJobs err:', err)
|
|
||||||
LoggerInstance.error(err.message)
|
LoggerInstance.error(err.message)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
return computeJobs
|
return computeJobs
|
||||||
}
|
}
|
||||||
export async function getComputeJobs(
|
export async function getComputeJobs(
|
||||||
@ -289,21 +273,18 @@ export async function getComputeJobs(
|
|||||||
user: accountId.toLowerCase()
|
user: accountId.toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('compute.ts getComputeJobs variables: ', variables)
|
|
||||||
const results = await fetchDataForMultipleChains(
|
const results = await fetchDataForMultipleChains(
|
||||||
assetDTAddress ? getComputeOrdersByDatatokenAddress : getComputeOrders,
|
assetDTAddress ? getComputeOrdersByDatatokenAddress : getComputeOrders,
|
||||||
variables,
|
variables,
|
||||||
assetDTAddress ? [asset?.chainId] : chainIds
|
assetDTAddress ? [asset?.chainId] : chainIds
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log('compute.ts getComputeJobs results getComputeOrders:', results)
|
|
||||||
let tokenOrders: TokenOrder[] = []
|
let tokenOrders: TokenOrder[] = []
|
||||||
results.map((result) => {
|
results.map((result) => {
|
||||||
result.orders.forEach((tokenOrder: TokenOrder) =>
|
result.orders.forEach((tokenOrder: TokenOrder) =>
|
||||||
tokenOrders.push(tokenOrder)
|
tokenOrders.push(tokenOrder)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
console.log('compute.ts getComputeJobs tokenOrders:', tokenOrders)
|
|
||||||
if (tokenOrders.length === 0) {
|
if (tokenOrders.length === 0) {
|
||||||
return computeResult
|
return computeResult
|
||||||
}
|
}
|
||||||
@ -311,7 +292,6 @@ export async function getComputeJobs(
|
|||||||
tokenOrders = tokenOrders.sort(
|
tokenOrders = tokenOrders.sort(
|
||||||
(a, b) => b.createdTimestamp - a.createdTimestamp
|
(a, b) => b.createdTimestamp - a.createdTimestamp
|
||||||
)
|
)
|
||||||
console.log('compute.ts getComputeJobs tokenOrders sorted:', tokenOrders)
|
|
||||||
|
|
||||||
const datatokenAddressList = tokenOrders.map(
|
const datatokenAddressList = tokenOrders.map(
|
||||||
(tokenOrder: TokenOrder) => tokenOrder.datatoken.address
|
(tokenOrder: TokenOrder) => tokenOrder.datatoken.address
|
||||||
@ -324,18 +304,12 @@ export async function getComputeJobs(
|
|||||||
chainIds
|
chainIds
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log('compute.ts assets:', assets)
|
|
||||||
const providerUrls: string[] = []
|
const providerUrls: string[] = []
|
||||||
assets.forEach((asset: Asset) =>
|
assets.forEach((asset: Asset) =>
|
||||||
providerUrls.push(asset.services[0].serviceEndpoint)
|
providerUrls.push(asset.services[0].serviceEndpoint)
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log('compute.ts providerUrls:', providerUrls)
|
|
||||||
computeResult.computeJobs = await getJobs(providerUrls, accountId, assets)
|
computeResult.computeJobs = await getJobs(providerUrls, accountId, assets)
|
||||||
console.log(
|
|
||||||
'compute.ts computeResult.computeJobs:',
|
|
||||||
computeResult.computeJobs
|
|
||||||
)
|
|
||||||
computeResult.isLoaded = true
|
computeResult.isLoaded = true
|
||||||
|
|
||||||
return computeResult
|
return computeResult
|
||||||
|
Loading…
Reference in New Issue
Block a user