Skip to content

Commit

Permalink
updated timestamp to UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmoySG committed Apr 22, 2023
1 parent d3e169a commit c11fbc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
18 changes: 8 additions & 10 deletions internal/server/handlers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
er "github.com/TanmoySG/wunderDB/pkg/wdb/errors"
"github.com/go-playground/validator/v10"
"github.com/gofiber/fiber/v2"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -97,7 +98,8 @@ func validateRequest(request any) *er.WdbError {
return nil
}

func (wh wdbHandlers) handleTransactions(c *fiber.Ctx, apiResponse response.ApiResponse, entities model.Entities) error {
func (wh wdbHandlers) handleTransactions(c *fiber.Ctx, apiResponse response.ApiResponse, entities model.Entities) {
var err error
if txlogs.IsTxnLoggable(apiResponse.Response.Action) {
if apiResponse.Response.Status == response.StatusSuccess {
databaseEntity := *entities.Databases
Expand All @@ -115,16 +117,12 @@ func (wh wdbHandlers) handleTransactions(c *fiber.Ctx, apiResponse response.ApiR
}

txnLog := txlogs.CreateTxLog(txnAction, txnActor, apiResponse.Response.Status, txnEntityPath, txnHttpDetails)

err := wh.wdbTxLogs.Log(txnLog)
if err != nil {
return err
}
err = wh.wdbTxLogs.Log(txnLog)
err = wh.wdbTxLogs.Commit()
if err != nil {
return err
}

}
}
return nil
if err != nil {
log.Errorf("error logging transaction: %s", err)
}
}
7 changes: 1 addition & 6 deletions internal/txlogs/txlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import (
"github.com/gofiber/fiber/v2"
)

var (
DatabaseTxnEntity TxnEntityType = "database"
CollectionTxnEntity TxnEntityType = "collection"
)

type TxnEntityType string

type TransactionLogs struct {
Expand All @@ -33,7 +28,7 @@ func CreateTxLog(txnAction, txnActor string, txnRequestStatus string, txnEntitie
EntityPath: txnEntities,
EntityType: getEntityType(txnEntities),
Status: getTxnStatus(txnRequestStatus),
Timestamp: float64(time.Now().Unix()),
Timestamp: float64(time.Now().UTC().Unix()),
TransactionDetails: txnDetails,
}
}
Expand Down

0 comments on commit c11fbc3

Please sign in to comment.