Include mod data in /workers/get-work
This commit is contained in:
parent
c7828eed45
commit
bcd15e1046
@ -16,17 +16,22 @@ router.get("/get-work", function(req, res) {
|
||||
limit: 1,
|
||||
where: {
|
||||
workerId: null
|
||||
}
|
||||
},
|
||||
include: [{
|
||||
model: db.Mod,
|
||||
include: [db.User]
|
||||
}]
|
||||
}).then(function(jobs) {
|
||||
if (jobs && jobs.length == 1) {
|
||||
var job = jobs[0]
|
||||
job.workerId = worker.id
|
||||
job.save()
|
||||
// job.workerId = worker.id
|
||||
// job.save()
|
||||
|
||||
var mod = db.convertRowToMod(job.mod)
|
||||
res.send({
|
||||
work: {
|
||||
author: job.author,
|
||||
basename: job.basename,
|
||||
type: job.work_type
|
||||
type: job.work_type,
|
||||
mod: mod.toPlainDictionary()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
@ -43,12 +43,13 @@ var Worker = sequelize.define("worker", {
|
||||
})
|
||||
|
||||
var Work = sequelize.define("work", {
|
||||
author: Sequelize.STRING(100),
|
||||
basename: Sequelize.STRING(100),
|
||||
work_type: Sequelize.ENUM("fetch", "scan", "forum")
|
||||
})
|
||||
|
||||
Mod.hasMany(Work)
|
||||
Worker.hasMany(Worker)
|
||||
Work.belongsTo(Worker)
|
||||
Work.belongsTo(Mod)
|
||||
|
||||
const CMod = require("./../../common/mod")
|
||||
function convertRowToMod(row) {
|
||||
@ -112,6 +113,8 @@ async.parallel([
|
||||
approved: true
|
||||
}
|
||||
}).then(function(mod) {
|
||||
mod = mod[0]
|
||||
|
||||
Worker.findOrCreate({
|
||||
where: {
|
||||
token: "foobar"
|
||||
@ -122,10 +125,10 @@ async.parallel([
|
||||
|
||||
Work.findOrCreate({
|
||||
where: {
|
||||
author: "rubenwardy",
|
||||
basename: "awards",
|
||||
modId: mod.id
|
||||
},
|
||||
defaults: {
|
||||
mod: mod,
|
||||
work_type: "fetch"
|
||||
}
|
||||
}).then(function(mod) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user