From 9edabb1140005e985d90be05aaf787b10e36e135 Mon Sep 17 00:00:00 2001 From: Nam Huynh Date: Thu, 19 Aug 2021 15:29:17 +0700 Subject: [PATCH] add AppVersion and AppVersionCode in model --- action_upsert.go | 23 ++++++++++++++++------- model.go | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/action_upsert.go b/action_upsert.go index 86649ec..d5e353e 100644 --- a/action_upsert.go +++ b/action_upsert.go @@ -71,13 +71,14 @@ func (s Service) Upsert(payload UpsertPayload) { appVersionCode = headerData.AppVersionCode } - pretty.Println("platform", platform) - pretty.Println("osName", osName) - pretty.Println("osVersion", osVersion) - pretty.Println("appVersion", appVersion) - pretty.Println("appVersionCode", appVersionCode) - pretty.Println("browserName", browserName) - pretty.Println("browserVersion", browserVersion) + pretty.Println("- platform", platform) + pretty.Println("- osName", osName) + pretty.Println("- osVersion", osVersion) + pretty.Println("- appVersion", appVersion) + pretty.Println("- appVersionCode", appVersionCode) + pretty.Println("- browserName", browserName) + pretty.Println("- browserVersion", browserVersion) + pretty.Println("----------------") // Find device id existed or not device := s.findByDeviceID(ctx, deviceID) @@ -97,6 +98,10 @@ func (s Service) Upsert(payload UpsertPayload) { payload.FirstSignInAt, now(), ).ToSql() + pretty.Println("Create new") + pretty.Println("stm -", stm) + pretty.Println("args -", args) + if _, err := s.DB.ExecContext(ctx, stm, args); err != nil { logger.Error("devicemngt - Upsert: Create new", logger.LogData{ "payload": payload, @@ -122,6 +127,10 @@ func (s Service) Upsert(payload UpsertPayload) { Where("device_id = ?", deviceID). ToSql() + pretty.Println("Update") + pretty.Println("stm -", stm) + pretty.Println("args -", args) + if _, err := s.DB.ExecContext(ctx, stm, args); err != nil { logger.Error("devicemngt - Upsert: Update", logger.LogData{ "payload": payload, diff --git a/model.go b/model.go index f5acac9..78b0c35 100644 --- a/model.go +++ b/model.go @@ -10,6 +10,8 @@ type Device struct { Platform string `db:"platform"` OSName string `db:"os_name"` OSVersion string `db:"os_version"` + AppVersion string `db:"app_version"` + AppVersionCode string `db:"app_version_code"` BrowserName string `db:"browser_name"` BrowserVersion string `db:"browser_version"` AuthToken string `db:"auth_token"`