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