4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/winewoo_core/repositories/mongo/winewoo_user_logs_mongo_repo.rb', line 4
def create(log_params)
wine_id = log_params.params["wine_id"] ? Moped::BSON::ObjectId.from_string(log_params.params["wine_id"]) : nil
wine = wine_id && Wine.find(wine_id)
interpro_id = wine ? wine.interpro_id : (log_params.interpro && log_params.interpro.id)
log = WinewooUserLog.create(
winewoo_user_id: (log_params.winewoo_user && log_params.winewoo_user.id),
interpro_id: interpro_id,
from_interpro_app: log_params.from_interpro_app,
location: ([log_params.geoloc[:lat].to_f, log_params.geoloc[:long].to_f]),
app_name: (log_params.user_agent && log_params.user_agent.application_name),
app_version: (log_params.user_agent && log_params.user_agent.application_version),
os: (log_params.user_agent && log_params.user_agent.device_os),
action: log_params.params["action"].to_s,
action_date: (DateTime.now),
wine_id: wine_id,
vintage_id: log_params.params["vintage_id"] ? Moped::BSON::ObjectId.from_string(log_params.params["vintage_id"]) : nil,
producer_id: (log_params.params["producer_id"] ? Moped::BSON::ObjectId.from_string(log_params.params["producer_id"]) : nil),
params: log_params.params["params"])
return log
end
|