1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00

Update to new device DB.

This commit is contained in:
Simo Kinnunen 2014-06-18 22:51:39 +09:00
parent 760e09290f
commit b9484019a3
8 changed files with 32 additions and 53 deletions

View file

@ -5,52 +5,28 @@ var logger = require('./logger')
var log = logger.createLogger('util:datautil')
var aliases = {
'KYY22': 'L02'
, 'SH-06DNERV': 'SH-06D_NERV'
}
var datautil = module.exports = Object.create(null)
datautil.applyData = function(device) {
var model = device.model
var name = device.name
var match = deviceData.find({
model: device.model
, name: device.product
})
if (model) {
var match = deviceData.find({model: model, name: name})
if (!match) {
if (aliases[model]) {
match = deviceData.find({model: aliases[model], name: name})
}
else {
if (!match) {
model = model.replace(/ /g, '_')
match = deviceData.find({model: model, name: name})
if (!match) {
model = model.replace(/_/g, '')
match = deviceData.find({model: model, name: name})
}
}
}
}
if (match) {
device.name = match.name.id
device.model = match.name.long
device.releasedAt = match.date
device.image = model + '.jpg' // TODO: check for icon/photo file existence
device.cpu = match.cpu
device.memory = match.memory
}
else {
log.warn(
'Device database does not have a match for device "%s" (model "%s")'
, device.serial
, device.model
)
}
if (match) {
device.name = match.name.id
device.releasedAt = match.date
device.image = match.image
device.cpu = match.cpu
device.memory = match.memory
}
else {
log.warn(
'Device database does not have a match for device "%s" (model "%s"/"%s")'
, device.serial
, device.model
, device.product
)
}
return device