Skip to content

Commit

Permalink
🐛 fix(linter): fix errors >>> ⏰ 10m
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalangel committed Jun 24, 2024
1 parent ca4d924 commit b2d0cfc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
7 changes: 6 additions & 1 deletion internal/model/dataframe.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package model

import "time"
import (
"time"

"gorm.io/gorm"
)

type DataFrame struct {
gorm.Model
Hash []byte `bson:"hash" json:"hash"`
Timestamp time.Time `bson:"timestamp" json:"timestamp"`
Data interface{} `bson:"data" gorm:"embedded" json:"data"`
Expand Down
8 changes: 7 additions & 1 deletion internal/model/proof.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package model

import "time"
import (
"time"

"gorm.io/gorm"
)

type Proof struct {
gorm.Model

Hash []byte `bson:"hash" json:"hash"`
Timestamp time.Time `bson:"timestamp" json:"timestamp"`
Signature [48]byte `bson:"signature" json:"signature"`
Expand Down
2 changes: 2 additions & 0 deletions internal/model/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package model

import (
sia "github.com/pouya-eghbali/go-sia/v2/pkg"
"gorm.io/gorm"
)

type Signer struct {
gorm.Model
Name string
EvmAddress string
PublicKey [96]byte
Expand Down
8 changes: 4 additions & 4 deletions internal/repository/mongo/assetprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error
return nil
}

func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]*ent.AssetPrice, error) {
currentRecords := []*ent.AssetPrice{}
func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) {
currentRecords := []model.AssetPrice{}
cursor, err := a.client.
GetConnection().
Database(config.App.Mongo.Database).
Expand All @@ -83,14 +83,14 @@ func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, na
}
}(cursor, ctx)
for cursor.Next(ctx) {
var result ent.AssetPrice
var result model.AssetPrice
err := cursor.Decode(&result)
if err != nil {
utils.Logger.With("err", err).Error("Cant decode signer record")
return nil, err
}

currentRecords = append(currentRecords, &result)
currentRecords = append(currentRecords, result)
}
if err := cursor.Err(); err != nil {
utils.Logger.With("err", err).Error("Cant fetch asset price records from database")
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/mongo/correctness.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type CorrectnessRepo struct {
client database.MongoDatabase
}

func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) {
func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]model.Correctness, error) {
cursor, err := c.client.
GetConnection().
Database(config.App.Mongo.Database).
Expand All @@ -34,7 +34,7 @@ func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, ti
return nil, consts.ErrInternalError
}

currentRecords, err := CursorToList[*ent.CorrectnessReport](ctx, cursor)
currentRecords, err := CursorToList[model.Correctness](ctx, cursor)
if err != nil {
utils.Logger.With("err", err).Error("Cant fetch correctness reports from database")
return nil, consts.ErrInternalError
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/mongo/eventlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type EventLogRepo struct {
client database.MongoDatabase
}

func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) {
func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) {
cursor, err := r.client.
GetConnection().
Database(config.App.Mongo.Database).
Expand All @@ -34,7 +34,7 @@ func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index
return nil, consts.ErrInternalError
}

currentRecords, err := CursorToList[*ent.EventLog](ctx, cursor)
currentRecords, err := CursorToList[model.EventLog](ctx, cursor)
if err != nil {
utils.Logger.With("err", err).Error("Cant fetch event log records from database")
return nil, consts.ErrInternalError
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/mongo/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]in
}
}(cursor, ctx)
for cursor.Next(ctx) {
var result ent.Signer
var result model.Signer
err := cursor.Decode(&result)
if err != nil {
utils.Logger.With("err", err).Error("Cant decode signer record")
return nil, err
}

ids = append(ids, result.ID)
ids = append(ids, int(result.ID))
}
if err := cursor.Err(); err != nil {
utils.Logger.With("err", err).Error("Cant fetch asset price records from database")
Expand Down

0 comments on commit b2d0cfc

Please sign in to comment.