1
0
Fork 0
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:
Simo Kinnunen 2014-01-28 15:47:29 +09:00
parent 881996557a
commit 48b4c2fd0e
7 changed files with 165 additions and 40 deletions

View file

@ -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
}))
}