From 2bfc236555229b6552e3791f95479c93cb4e719c Mon Sep 17 00:00:00 2001 From: Nam Huynh Date: Thu, 19 Aug 2021 15:48:05 +0700 Subject: [PATCH] remove logs --- action_upsert.go | 24 ++++++++---------------- get_header_data.go | 15 --------------- find_by_device_id.go => helper.go | 13 +++++++++++++ 3 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 get_header_data.go rename find_by_device_id.go => helper.go (55%) diff --git a/action_upsert.go b/action_upsert.go index 4bc60b7..10e9370 100644 --- a/action_upsert.go +++ b/action_upsert.go @@ -7,7 +7,6 @@ import ( "github.com/Selly-Modules/logger" "github.com/Selly-Modules/mongodb" - "github.com/kr/pretty" ua "github.com/mssola/user_agent" ) @@ -71,21 +70,18 @@ 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("----------------") + // 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) - pretty.Println("device.ID", device.ID) - pretty.Println("mongodb.IsValidID(device.ID)", mongodb.IsValidID(device.ID)) - if !mongodb.IsValidID(device.ID) { // If not exist, create new stm, args, _ := s.Builder.Insert(TableDeviceMngt). @@ -101,8 +97,6 @@ func (s Service) Upsert(payload UpsertPayload) { payload.FirstSignInAt, now(), ).ToSql() - pretty.Println("Create new") - if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil { logger.Error("devicemngt - Upsert: Create new", logger.LogData{ "payload": payload, @@ -128,8 +122,6 @@ func (s Service) Upsert(payload UpsertPayload) { Where("device_id = ?", deviceID). ToSql() - pretty.Println("Update") - if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil { logger.Error("devicemngt - Upsert: Update", logger.LogData{ "payload": payload, diff --git a/get_header_data.go b/get_header_data.go deleted file mode 100644 index 4489ea0..0000000 --- a/get_header_data.go +++ /dev/null @@ -1,15 +0,0 @@ -package devicemngt - -import "net/http" - -// getHeaderData ... -func getHeaderData(headers http.Header) HeaderData { - return HeaderData{ - UserAgent: headers.Get("User-Agent"), - DeviceID: headers.Get("Deviceid"), - AppVersion: headers.Get("App-Version"), - AppVersionCode: headers.Get("App-Version-Code"), - OSName: headers.Get("Os-Name"), - OSVersion: headers.Get("Os-Version"), - } -} diff --git a/find_by_device_id.go b/helper.go similarity index 55% rename from find_by_device_id.go rename to helper.go index 53843ed..049d93b 100644 --- a/find_by_device_id.go +++ b/helper.go @@ -2,6 +2,7 @@ package devicemngt import ( "context" + "net/http" "github.com/Selly-Modules/logger" ) @@ -19,3 +20,15 @@ func (s Service) findByDeviceID(ctx context.Context, id string) (result Device) return } + +// getHeaderData ... +func getHeaderData(headers http.Header) HeaderData { + return HeaderData{ + UserAgent: headers.Get("User-Agent"), + DeviceID: headers.Get("Deviceid"), + AppVersion: headers.Get("App-Version"), + AppVersionCode: headers.Get("App-Version-Code"), + OSName: headers.Get("Os-Name"), + OSVersion: headers.Get("Os-Version"), + } +}