mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 09:53:21 +02:00
Update device instead of upsert so that we don't lose data between unplugs.
This commit is contained in:
@@ -52,20 +52,24 @@ dbapi.saveDeviceLog = function(serial, entry) {
|
||||
}
|
||||
|
||||
dbapi.saveDevice = function(serial, device) {
|
||||
return db.run(r.table('devices').insert({
|
||||
serial: serial
|
||||
, present: true
|
||||
, provider: device.provider
|
||||
, owner: null
|
||||
, status: device.status
|
||||
, ready: false
|
||||
, statusChangedAt: r.now()
|
||||
, createdAt: r.now()
|
||||
, lastHeartbeatAt: r.now()
|
||||
}
|
||||
, {
|
||||
upsert: true
|
||||
}))
|
||||
var data = {
|
||||
present: true
|
||||
, provider: device.provider
|
||||
, owner: null
|
||||
, status: device.status
|
||||
, ready: false
|
||||
, statusChangedAt: r.now()
|
||||
, createdAt: r.now()
|
||||
, lastHeartbeatAt: r.now()
|
||||
}
|
||||
return db.run(r.table('users').get(serial).update(data))
|
||||
.then(function(stats) {
|
||||
if (stats.skipped) {
|
||||
data.serial = serial
|
||||
return db.run(r.table('devices').insert(data))
|
||||
}
|
||||
return stats
|
||||
})
|
||||
}
|
||||
|
||||
dbapi.saveDeviceStatus = function(serial, status) {
|
||||
|
||||
Reference in New Issue
Block a user