{"action":"opened","issue":{"url":"https://api.github.com/repos/meumobi/sitebuilder/issues/302","labels_url":"https://api.github.com/repos/meumobi/sitebuilder/issues/302/labels{/name}","comments_url":"https://api.github.com/repos/meumobi/sitebuilder/issues/302/comments","events_url":"https://api.github.com/repos/meumobi/sitebuilder/issues/302/events","html_url":"https://github.com/meumobi/sitebuilder/issues/302","id":130503626,"number":302,"title":"when I remove a visitor its device remains on db","user":{"login":"elbidone","id":9011612,"avatar_url":"https://avatars.githubusercontent.com/u/9011612?v=3","gravatar_id":"","url":"https://api.github.com/users/elbidone","html_url":"https://github.com/elbidone","followers_url":"https://api.github.com/users/elbidone/followers","following_url":"https://api.github.com/users/elbidone/following{/other_user}","gists_url":"https://api.github.com/users/elbidone/gists{/gist_id}","starred_url":"https://api.github.com/users/elbidone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elbidone/subscriptions","organizations_url":"https://api.github.com/users/elbidone/orgs","repos_url":"https://api.github.com/users/elbidone/repos","events_url":"https://api.github.com/users/elbidone/events{/privacy}","received_events_url":"https://api.github.com/users/elbidone/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/meumobi/sitebuilder/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/meumobi/sitebuilder/labels/Users","name":"Users","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"juliogreff","id":58992,"avatar_url":"https://avatars.githubusercontent.com/u/58992?v=3","gravatar_id":"","url":"https://api.github.com/users/juliogreff","html_url":"https://github.com/juliogreff","followers_url":"https://api.github.com/users/juliogreff/followers","following_url":"https://api.github.com/users/juliogreff/following{/other_user}","gists_url":"https://api.github.com/users/juliogreff/gists{/gist_id}","starred_url":"https://api.github.com/users/juliogreff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliogreff/subscriptions","organizations_url":"https://api.github.com/users/juliogreff/orgs","repos_url":"https://api.github.com/users/juliogreff/repos","events_url":"https://api.github.com/users/juliogreff/events{/privacy}","received_events_url":"https://api.github.com/users/juliogreff/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2016-02-01T22:24:53Z","updated_at":"2016-02-01T22:24:53Z","closed_at":null,"body":"I've tested on PROD with following visitor and device:\r\n\r\n```bash\r\n> db.devices.find({uuid: \"b1c69c42-0d9d-71c5-3552-550589379488\", site_id: 458})\r\n{  \r\n  \"_id\":ObjectId(\"56a7d9c79a645ddb7b8b4718\"),\r\n  \"uuid\":\"b1c69c42-0d9d-71c5-3552-550589379488\",\r\n  \"user_id\":\"55f7160b9a645d176f2ac608\",\r\n  \"site_id\":NumberLong(458),\r\n  \"push_id\":\"APA91bHhub9YVGBhOYRTJ-jPTfi7S3pBB9H13HAhDqFtdQeC2vDpqK0WhPbPf9OLUnXpMtd8Pjex9db9vRSENkZlZ4um02agi5tc4TgV_BeN2OwCxzPGCDxrMUZOk00V_G5NWbf-dtWv\",\r\n  \"model\":\"GT-I8190L\",\r\n  \"platform\":\"Android\",\r\n  \"platform_version\":\"4.1.2\",\r\n  \"app_version\":\"1.2.0\",\r\n  \"app_build\":NumberLong(283),\r\n  \"created\":  ISODate(\"2016-01-26T20:40:39  Z\"),\r\n  \"modified\":  ISODate(\"2016-02-01T14:39:26  Z\")\r\n}\r\n> db.visitors.find({_id:ObjectId(\"55f7160b9a645d176f2ac608\")})\r\n{  \r\n  \"_id\":ObjectId(\"55f7160b9a645d176f2ac608\"),\r\n  \"email\":\"victor.dias@meumobi.com\",\r\n  \"first_name\":\"Victor\",\r\n  \"last_name\":\"Dias\",\r\n  \"site_id\":NumberLong(458),\r\n  \"hashed_password\":\"3b610c22520f3efcfd92d8f75e45feff65dd132f\",\r\n  \"auth_token\":\"bec27c24fa5a34fc09e515ef82861ea7997f714d\",\r\n  \"should_renew_password\":false,\r\n  \"groups\":[  \r\n    \"meumobi\"\r\n  ],\r\n  \"last_login\":  ISODate(\"2016-02-01T21:00:11  Z\"),\r\n  \"created\":null,\r\n  \"modified\":  ISODate(\"2016-02-01T21:01:15  Z\")\r\n}\r\n```\r\n\r\nAfter removing visitor form dashboard we can observe on mongo that visitor doesn't exist anymore but its device remains with the reference of obsolet user_id:\r\n```bash\r\n> db.visitors.find({_id:ObjectId(\"55f7160b9a645d176f2ac608\")})\r\n> db.devices.find({uuid: \"b1c69c42-0d9d-71c5-3552-550589379488\", site_id: 458})\r\n{  \r\n  \"_id\":ObjectId(\"56a7d9c79a645ddb7b8b4718\"),\r\n  \"uuid\":\"b1c69c42-0d9d-71c5-3552-550589379488\",\r\n  \"user_id\":\"55f7160b9a645d176f2ac608\",\r\n  \"site_id\":NumberLong(458),\r\n  \"push_id\":\"APA91bHhub9YVGBhOYRTJ-jPTfi7S3pBB9H13HAhDqFtdQeC2vDpqK0WhPbPf9OLUnXpMtd8Pjex9db9vRSENkZlZ4um02agi5tc4TgV_BeN2OwCxzPGCDxrMUZOk00V_G5NWbf-dtWv\",\r\n  \"model\":\"GT-I8190L\",\r\n  \"platform\":\"Android\",\r\n  \"platform_version\":\"4.1.2\",\r\n  \"app_version\":\"1.2.0\",\r\n  \"app_build\":NumberLong(283),\r\n  \"created\":  ISODate(\"2016-01-26T20:40:39  Z\"),\r\n  \"modified\":  ISODate(\"2016-02-01T14:39:26  Z\")\r\n}\r\n```"}}