Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinlink committed May 16, 2024
1 parent bc43bd4 commit e9d0a77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions dao/listing.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func (dao *DbListingDao) Create(context context.Context, listing *database.Listi
}

func (dao *DbListingDao) GetByGroupId(context context.Context, groupId int64) (database.Listing, error) {
var item = database.Listing{}
if err := dao.db.Where("group_id = ?", groupId).Take(&item).Error; err != nil {
return item, err
var listing = database.Listing{}
if err := dao.db.Where("group_id = ?", groupId).Take(&listing).Error; err != nil {
return listing, err
}
return item, nil
return listing, nil
}
7 changes: 6 additions & 1 deletion monitor/gnfd_block_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,18 @@ func (p *GnfdBlockProcessor) handleEventCreateGroup(blockHeight uint64, event ab
}

listing, err := p.listingDao.GetByGroupId(context.Background(), int64(createGroup.GroupId.Uint64()))
if err == nil {
if err == nil && listing.Id > 0 {
return fmt.Sprintf("insert into items (category_id, group_id, group_name, name, owner_address, status, description, url, listed_at, created_gnfd_height, price)"+
" values (%d, %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %s)",
categoryId, createGroup.GroupId.Uint64(), createGroup.GroupName, resourceName, createGroup.Owner,
database.ItemListed, escape(extra.Desc), escape(extra.Url), block.Time.Unix(), blockHeight, listing.Price), nil
}

if err != nil {
util.Logger.Errorf("processor: %s, fail to get listing err: %s", p.Name(), err)
return rawSql, err
}

return fmt.Sprintf("insert into items (category_id, group_id, group_name, name, owner_address, status, description, url, listed_at, created_gnfd_height)"+
" values (%d, %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d)",
categoryId, createGroup.GroupId.Uint64(), createGroup.GroupName, resourceName, createGroup.Owner,
Expand Down
2 changes: 1 addition & 1 deletion restapi/configure_mind_marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func configureAPI(api *operations.MindMarketplaceAPI) http.Handler {

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

api.JSONConsumer = runtime.JSONConsumer()
Expand Down

0 comments on commit e9d0a77

Please sign in to comment.