remove logs
This commit is contained in:
parent
61c8413d3c
commit
2bfc236555
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
"github.com/Selly-Modules/logger"
|
"github.com/Selly-Modules/logger"
|
||||||
"github.com/Selly-Modules/mongodb"
|
"github.com/Selly-Modules/mongodb"
|
||||||
"github.com/kr/pretty"
|
|
||||||
ua "github.com/mssola/user_agent"
|
ua "github.com/mssola/user_agent"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -71,21 +70,18 @@ func (s Service) Upsert(payload UpsertPayload) {
|
||||||
appVersionCode = headerData.AppVersionCode
|
appVersionCode = headerData.AppVersionCode
|
||||||
}
|
}
|
||||||
|
|
||||||
pretty.Println("- platform", platform)
|
// pretty.Println("- platform", platform)
|
||||||
pretty.Println("- osName", osName)
|
// pretty.Println("- osName", osName)
|
||||||
pretty.Println("- osVersion", osVersion)
|
// pretty.Println("- osVersion", osVersion)
|
||||||
pretty.Println("- appVersion", appVersion)
|
// pretty.Println("- appVersion", appVersion)
|
||||||
pretty.Println("- appVersionCode", appVersionCode)
|
// pretty.Println("- appVersionCode", appVersionCode)
|
||||||
pretty.Println("- browserName", browserName)
|
// pretty.Println("- browserName", browserName)
|
||||||
pretty.Println("- browserVersion", browserVersion)
|
// pretty.Println("- browserVersion", browserVersion)
|
||||||
pretty.Println("----------------")
|
// pretty.Println("----------------")
|
||||||
|
|
||||||
// Find device id existed or not
|
// Find device id existed or not
|
||||||
device := s.findByDeviceID(ctx, deviceID)
|
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 !mongodb.IsValidID(device.ID) {
|
||||||
// If not exist, create new
|
// If not exist, create new
|
||||||
stm, args, _ := s.Builder.Insert(TableDeviceMngt).
|
stm, args, _ := s.Builder.Insert(TableDeviceMngt).
|
||||||
|
@ -101,8 +97,6 @@ func (s Service) Upsert(payload UpsertPayload) {
|
||||||
payload.FirstSignInAt, now(),
|
payload.FirstSignInAt, now(),
|
||||||
).ToSql()
|
).ToSql()
|
||||||
|
|
||||||
pretty.Println("Create new")
|
|
||||||
|
|
||||||
if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil {
|
if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil {
|
||||||
logger.Error("devicemngt - Upsert: Create new", logger.LogData{
|
logger.Error("devicemngt - Upsert: Create new", logger.LogData{
|
||||||
"payload": payload,
|
"payload": payload,
|
||||||
|
@ -128,8 +122,6 @@ func (s Service) Upsert(payload UpsertPayload) {
|
||||||
Where("device_id = ?", deviceID).
|
Where("device_id = ?", deviceID).
|
||||||
ToSql()
|
ToSql()
|
||||||
|
|
||||||
pretty.Println("Update")
|
|
||||||
|
|
||||||
if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil {
|
if _, err := s.DB.ExecContext(ctx, stm, args...); err != nil {
|
||||||
logger.Error("devicemngt - Upsert: Update", logger.LogData{
|
logger.Error("devicemngt - Upsert: Update", logger.LogData{
|
||||||
"payload": payload,
|
"payload": payload,
|
||||||
|
|
|
@ -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"),
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package devicemngt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/Selly-Modules/logger"
|
"github.com/Selly-Modules/logger"
|
||||||
)
|
)
|
||||||
|
@ -19,3 +20,15 @@ func (s Service) findByDeviceID(ctx context.Context, id string) (result Device)
|
||||||
|
|
||||||
return
|
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"),
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue