|
|
@ -93,7 +93,8 @@ class HeroUnion { |
|
|
|
* notify_url: '', |
|
|
|
* notify_url: '', |
|
|
|
* results: [], |
|
|
|
* results: [], |
|
|
|
* created: 0, //timestamp in seconds
|
|
|
|
* created: 0, //timestamp in seconds
|
|
|
|
* updated: 0 //timestamp in seconds
|
|
|
|
* updated: 0, //timestamp in seconds
|
|
|
|
|
|
|
|
* error: '' |
|
|
|
* } |
|
|
|
* } |
|
|
|
**/ |
|
|
|
**/ |
|
|
|
createTask(uuid, url, platform, data_mode, notify_url, country, lang) { |
|
|
|
createTask(uuid, url, platform, data_mode, notify_url, country, lang) { |
|
|
@ -144,11 +145,14 @@ class HeroUnion { |
|
|
|
let searchResult = null; |
|
|
|
let searchResult = null; |
|
|
|
|
|
|
|
|
|
|
|
for (const task of this.tasks) { |
|
|
|
for (const task of this.tasks) { |
|
|
|
|
|
|
|
if (searchResult) {break;} |
|
|
|
|
|
|
|
|
|
|
|
if (task.status == 'waiting') { |
|
|
|
if (task.status == 'waiting') { |
|
|
|
if (typeof(platform) != 'undefined' && platform) { |
|
|
|
if (typeof(platform) != 'undefined' && platform) { |
|
|
|
if (platform == task.platform) { |
|
|
|
if (platform == task.platform) { |
|
|
|
searchResult = task; |
|
|
|
searchResult = task; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
|
|
|
|
searchResult = null; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -157,6 +161,7 @@ class HeroUnion { |
|
|
|
if (country == task.country) { |
|
|
|
if (country == task.country) { |
|
|
|
searchResult = task; |
|
|
|
searchResult = task; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
|
|
|
|
searchResult = null; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -165,6 +170,7 @@ class HeroUnion { |
|
|
|
if (lang == task.lang) { |
|
|
|
if (lang == task.lang) { |
|
|
|
searchResult = task; |
|
|
|
searchResult = task; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
|
|
|
|
searchResult = null; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -173,12 +179,19 @@ class HeroUnion { |
|
|
|
if (data_mode == task.data_mode) { |
|
|
|
if (data_mode == task.data_mode) { |
|
|
|
searchResult = task; |
|
|
|
searchResult = task; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
|
|
|
|
searchResult = null; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (searchResult) { |
|
|
|
|
|
|
|
let taskIndex = this.tasks.findIndex((item) => item.id == searchResult.id); |
|
|
|
|
|
|
|
this.tasks[taskIndex].status = 'running'; |
|
|
|
|
|
|
|
searchResult.status = 'running'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return searchResult; |
|
|
|
return searchResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -189,6 +202,8 @@ class HeroUnion { |
|
|
|
let taskIndex = this.tasks.findIndex((item) => item.id == id); |
|
|
|
let taskIndex = this.tasks.findIndex((item) => item.id == id); |
|
|
|
if (taskIndex > -1) { |
|
|
|
if (taskIndex > -1) { |
|
|
|
if (this.isDataTooLarge(data)) { |
|
|
|
if (this.isDataTooLarge(data)) { |
|
|
|
|
|
|
|
this.tasks[taskIndex].status = 'failed'; |
|
|
|
|
|
|
|
this.tasks[taskIndex].error = 'Result is too large to save.'; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -202,6 +217,7 @@ class HeroUnion { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.tasks[taskIndex].updated = this.getTimestampInSeconds(); |
|
|
|
this.tasks[taskIndex].updated = this.getTimestampInSeconds(); |
|
|
|
|
|
|
|
this.tasks[taskIndex].status = 'done'; |
|
|
|
|
|
|
|
|
|
|
|
done = true; |
|
|
|
done = true; |
|
|
|
} |
|
|
|
} |
|
|
@ -210,8 +226,8 @@ class HeroUnion { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//查询某个任务的状态及其数据
|
|
|
|
//查询某个任务的状态及其数据
|
|
|
|
getTaskById() { |
|
|
|
getTaskById(id) { |
|
|
|
|
|
|
|
return this.tasks.find((item) => item.id == id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//任务完成触发回调通知
|
|
|
|
//任务完成触发回调通知
|
|
|
|