Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add listing table to fix monitor interval mismatch between bsc and gnfd #23

Merged
merged 5 commits into from
May 16, 2024

Conversation

cosinlink
Copy link
Collaborator

Description

add listing table to fix monitor interval mismatch between bsc and gnfd

@@ -230,6 +232,14 @@ func (p *GnfdBlockProcessor) handleEventCreateGroup(blockHeight uint64, event ab
return rawSql, err
}

listing, err := p.listingDao.GetByGroupId(context.Background(), int64(createGroup.GroupId.Uint64()))
if err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check whether listing is nil or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@@ -230,6 +232,14 @@ func (p *GnfdBlockProcessor) handleEventCreateGroup(blockHeight uint64, event ab
return rawSql, err
}

listing, err := p.listingDao.GetByGroupId(context.Background(), int64(createGroup.GroupId.Uint64()))
if err == nil {
return fmt.Sprintf("insert into items (category_id, group_id, group_name, name, owner_address, status, description, url, listed_at, created_gnfd_height, price)"+
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set price as well here

@@ -51,7 +51,7 @@ func configureAPI(api *operations.MindMarketplaceAPI) http.Handler {

go func() {
http.Handle("/metrics", promhttp.Handler())
util.Logger.Fatal(http.ListenAndServe(":9292", nil))
util.Logger.Fatal(http.ListenAndServe(":9293", nil))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not commit this change, it will affect the metrics in testnet/mainnet

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

dao/listing.go Outdated

func (dao *DbListingDao) GetByGroupId(context context.Context, groupId int64) (database.Listing, error) {
var item = database.Listing{}
if err := dao.db.Preload("Stats").Where("group_id = ?", groupId).Take(&item).Error; err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listing has no Stats field. No preload is needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

type Listing struct {
Id int64 `json:"id" gorm:"primaryKey"`
Price decimal.Decimal `json:"price" gorm:"type:decimal(65,0);"`
ListBscHeight uint64 `gorm:"NOT NULL;index:idx_list_bsc_height"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove index:idx_list_bsc_height this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

dao/listing.go Outdated
}

func (dao *DbListingDao) GetByGroupId(context context.Context, groupId int64) (database.Listing, error) {
var item = database.Listing{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename item to listing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

@cosinlink cosinlink merged commit 055b61b into main May 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants