Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jan 9, 2023
1 parent c73282a commit 0c8c053
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 58 deletions.
27 changes: 1 addition & 26 deletions cmd/metadata/models/contract_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,11 @@ func (cm *ContractMetadata) GetStatus() Status {
return cm.Status
}

// GetRetryCount -
func (cm *ContractMetadata) GetRetryCount() int8 {
return cm.RetryCount
}

// GetID -
func (cm *ContractMetadata) GetID() uint64 {
return cm.ID
}

// GetLink -
func (cm *ContractMetadata) GetLink() string {
return cm.Link
}

// IncrementRetryCount -
func (cm *ContractMetadata) IncrementRetryCount() {
cm.RetryCount += 1
}

// SetMetadata -
func (cm *ContractMetadata) SetMetadata(data JSONB) {
cm.Metadata = data
}

// SetStatus -
func (cm *ContractMetadata) SetStatus(status Status) {
cm.Status = status
}

// BeforeInsert -
func (cm *ContractMetadata) BeforeInsert(ctx context.Context) (context.Context, error) {
cm.UpdatedAt = time.Now().Unix()
Expand Down Expand Up @@ -164,7 +139,7 @@ func (contracts *Contracts) Save(metadata []*ContractMetadata) error {

_, err := contracts.db.DB().Model(&savings).
OnConflict("(network, contract) DO UPDATE").
Set("metadata = excluded.metadata, link = excluded.link, updated_at = excluded.updated_at, update_id = excluded.update_id, status = excluded.status").
Set("metadata = excluded.metadata, link = excluded.link, updated_at = excluded.updated_at, update_id = excluded.update_id, status = excluded.status, retry_count = excluded.retry_count").
Insert()
return err
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/metadata/models/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ type ModelRepository[T Model] interface {
// Model -
type Model interface {
GetStatus() Status
GetRetryCount() int8
GetID() uint64
GetLink() string
TableName() string
IncrementRetryCount()
SetMetadata(data JSONB)
SetStatus(status Status)
}
27 changes: 1 addition & 26 deletions cmd/metadata/models/token_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,11 @@ func (tm TokenMetadata) GetStatus() Status {
return tm.Status
}

// GetRetryCount -
func (tm TokenMetadata) GetRetryCount() int8 {
return tm.RetryCount
}

// GetID -
func (tm TokenMetadata) GetID() uint64 {
return tm.ID
}

// GetLink -
func (tm TokenMetadata) GetLink() string {
return tm.Link
}

// IncrementRetryCount -
func (tm *TokenMetadata) IncrementRetryCount() {
tm.RetryCount += 1
}

// SetMetadata -
func (tm *TokenMetadata) SetMetadata(data JSONB) {
tm.Metadata = data
}

// SetStatus -
func (tm *TokenMetadata) SetStatus(status Status) {
tm.Status = status
}

// BeforeInsert -
func (tm *TokenMetadata) BeforeInsert(ctx context.Context) (context.Context, error) {
tm.UpdatedAt = time.Now().Unix()
Expand Down Expand Up @@ -185,7 +160,7 @@ func (tokens *Tokens) Save(metadata []*TokenMetadata) error {

_, err := tokens.db.DB().Model(&savings).
OnConflict("(network, contract, token_id) DO UPDATE").
Set("metadata = excluded.metadata, link = excluded.link, updated_at = excluded.updated_at, update_id = excluded.update_id, status = excluded.status").
Set("metadata = excluded.metadata, link = excluded.link, updated_at = excluded.updated_at, update_id = excluded.update_id, status = excluded.status, retry_count = excluded.retry_count").
Insert()
return err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/metadata/thumbnail/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Service struct {
network string
workersCount int
tasks chan models.TokenMetadata
wg sync.WaitGroup
wg *sync.WaitGroup
}

// New -
Expand All @@ -56,6 +56,7 @@ func New(storage storage.Storage, db *models.Tokens, network string, gateways []
timeout: time.Second * 10,
workersCount: 10,
tasks: make(chan models.TokenMetadata, 512),
wg: new(sync.WaitGroup),
}

for i := range opts {
Expand Down

0 comments on commit 0c8c053

Please sign in to comment.