Class: WinewooCore::Repositories::Mongo::InterproWinewooUserLogsMongoRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/winewoo_core/repositories/mongo/interpro_winewoo_user_logs_mongo_repo.rb

Instance Method Summary collapse

Instance Method Details

#create(log_params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/winewoo_core/repositories/mongo/interpro_winewoo_user_logs_mongo_repo.rb', line 4

def create(log_params)
  WinewooUserLog.create(
    winewoo_user_id: (log_params.winewoo_user && log_params.winewoo_user.id),
    interpro_id: (log_params.interpro && log_params.interpro.id),
    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: log_params.params["wine_id"] ? Moped::BSON::ObjectId.from_string(log_params.params["wine_id"]) : "",
    vintage_id: log_params.params["vintage_id"] ? Moped::BSON::ObjectId.from_string(log_params.params["vintage_id"]) : "",
    producer_id: log_params.params["producer_id"] ? Moped::BSON::ObjectId.from_string(log_params.params["producer_id"]) : "",
    params: log_params.params["params"].to_h)
end