<commit_before># HOX: before seeding you should have at least one user in your database!

#To start from a fresh database (on the command line):
#rake db:drop db:create db:migrate
#rails c
# > User.create name: "[name]", password:"[password]", password_confirmation:"[password]"
# > quit
#rake:db seed

# Create profile for Thingsee One beta
dp = DeviceProfile.create sw_version:"2015.05.21.8_Thingsee_Retail", hw_version:"0402", device_type:"Thingsee", profile_name:"Thingsee One beta version"

# Create device
dp.devices.create device_id:"XNG51760148", user_id:User.first.id

# Create sensor_types and add sensors to profile (from device.jsn on the device and TS Engine API 00.20)
# Commented out sensors have no specification in the API
st1=SensorType.create name:"Temperature"
st1.sensors.create device_profile_id:dp.id, name:"ThingseeOne temperature sensor", address:"0x00060100"

st2=SensorType.create name:"Humidity"
st2.sensors.create device_profile_id:dp.id, name:"ThingseeOne humidity sensor", address:"0x00060200"

st3=SensorType.create name:"Air pressure"
st3.sensors.create device_profile_id:dp.id, name:"ThingseeOne air pressure sensor", address:"0x00060400"

#st4=SensorType.create name:"xxx"
#st4.sensors.create device_profile_id:dp.id, name:"ThingseeOne xxx sensor", address:"0x00060101"

st5=SensorType.create name:"Power button pressed"
st5.sensors.create device_profile_id:dp.id, name:"ThingseeOne power button pressed sensor", address:"0x00070100"

st6=SensorType.create name:"Longitudinal acceleration"
st6.sensors.create device_profile_id:dp.id, name:"ThingseeOne longitudinal acceleratio sensor", address:"0x00050100"

st7=SensorType.create name:"Lateral acceleration"<commit_msg>fixing seeds.rb so seeding doesn't fail even if there are no users in the db<commit_after>#To start from a fresh database (on the command line):
# rake db:reset

# If you wish to seed devices, before seeding you should have at least one user in your database.
# Uncomment and edit relevant line below, then run the following commands:
#rake db:drop db:create db:migrate
#rails c
# > User.create username: "[username]", password:"[password]", password_confirmation:"[password]"
# > quit
#rake:db seed

# Create profile for Thingsee One beta
dp = DeviceProfile.create sw_version:"2015.05.21.8_Thingsee_Retail", hw_version:"0402", device_type:"Thingsee", profile_name:"Thingsee One beta version"

# Create device. HOX: username must exist in the database lest seeding fail
# dp.devices.create device_id:"XNG51760148", user_id:(User.find_by username:"[username]").id

# Create sensor_types and add sensors to profile (from device.jsn on the device and TS Engine API 00.20)
# Commented out sensors have no specification in the API
st1=SensorType.create name:"Temperature"
st1.sensors.create device_profile_id:dp.id, name:"ThingseeOne temperature sensor", address:"0x00060100"

st2=SensorType.create name:"Humidity"
st2.sensors.create device_profile_id:dp.id, name:"ThingseeOne humidity sensor", address:"0x00060200"

st3=SensorType.create name:"Air pressure"
st3.sensors.create device_profile_id:dp.id, name:"ThingseeOne air pressure sensor", address:"0x00060400"

#st4=SensorType.create name:"xxx"
#st4.sensors.create device_profile_id:dp.id, name:"ThingseeOne xxx sensor", address:"0x00060101"

st5=SensorType.create name:"Power button pressed"
st5.sensors.create device_profile_id:dp.id, name:"ThingseeOne power button pressed sensor", address:"0x00070100"

st6=SensorType.create name:"Longitudinal acceleration"
st6.sensors.create device_profile_id:dp.id, name:"ThingseeOne longitudinal acceleratio sensor", address:"0x00050100"

st7=SensorType.create name:"Lateral acceleration"
{'fraction_non_alphanumeric': 0.1051059206952743, 'fraction_numerical': 0.049972840847365564, 'mean_word_length': 7.295045045045045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6668900', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1148, 'n_words': 327}