mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Save devices to database.
This commit is contained in:
parent
881996557a
commit
48b4c2fd0e
7 changed files with 165 additions and 40 deletions
|
@ -12,3 +12,32 @@ module.exports.saveUserAfterLogin = function(user) {
|
|||
upsert: true
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports.saveDeviceStatus = function(serial, status) {
|
||||
return db.run(r.table('devices').get(serial).update({
|
||||
status: status
|
||||
, statusChangedAt: r.now()
|
||||
}))
|
||||
.then(function(stats) {
|
||||
if (stats.skipped) {
|
||||
return db.run(r.table('devices').insert({
|
||||
serial: serial
|
||||
, status: status
|
||||
, statusChangedAt: r.now()
|
||||
, createdAt: r.now()
|
||||
}))
|
||||
}
|
||||
return stats
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.saveDeviceIdentity = function(serial, identity) {
|
||||
return db.run(r.table('devices').get(serial).update({
|
||||
platform: identity.platform
|
||||
, manufacturer: identity.manufacturer
|
||||
, model: identity.model
|
||||
, version: identity.version
|
||||
, abi: identity.abi
|
||||
, sdk: identity.sdk
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue