Skip to content

Commit f0ed57d

Browse files
committed
Crontab - update code for capture more faster
1 parent 1c35eb4 commit f0ed57d

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

internal/repository/nft_auctions_available.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"dapp-moderator/internal/entity"
66
"dapp-moderator/utils"
7-
"go.mongodb.org/mongo-driver/bson/primitive"
87
"strings"
98
"time"
109

@@ -67,12 +66,13 @@ func (r *Repository) NftWithoutCapturedImage(contractAddress string, offset int,
6766
bson.D{
6867
{"$match",
6968
bson.D{
69+
{"token_id", "156"},
7070
{"collection_address", strings.ToLower(contractAddress)},
71-
{"image_capture_at", bson.D{{"$in", bson.A{
72-
"",
73-
primitive.Null{},
74-
},
75-
}}},
71+
//{"image_capture_at", bson.D{{"$in", bson.A{
72+
// "",
73+
// primitive.Null{},
74+
//},
75+
//}}},
7676
},
7777
},
7878
},

internal/repository/soul_image_histories.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ func (r *Repository) InsertSoulImageHistory(obj *entity.SoulImageHistories) erro
1919
}
2020

2121
// aggregate data to view_soul_nfts
22-
func (r *Repository) PrepareSoulData(wg *sync.WaitGroup) error {
22+
func (r *Repository) PrepareSoulData(wg *sync.WaitGroup, nfts []string) error {
2323
defer wg.Done()
2424

2525
fAll := bson.A{
26-
bson.D{{"$match", bson.D{{"collection_address", strings.ToLower(os.Getenv("SOUL_CONTRACT"))}}}},
26+
bson.D{{"$match", bson.D{
27+
{"collection_address", strings.ToLower(os.Getenv("SOUL_CONTRACT"))},
28+
{"token_id", bson.M{"$in": nfts}},
29+
}}},
2730
bson.D{
2831
{"$lookup",
2932
bson.D{

internal/usecase/soul_nft_image.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func (u *Usecase) SoulNftImageCrontab() error {
8080
break
8181
}
8282

83+
tokenIDs := []string{}
84+
for _, nft := range nfts {
85+
tokenIDs = append(tokenIDs, nft.TokenID)
86+
}
87+
8388
var wg1 sync.WaitGroup
8489
var wg2 sync.WaitGroup
8590
var wg3 sync.WaitGroup
@@ -127,7 +132,7 @@ func (u *Usecase) SoulNftImageCrontab() error {
127132
ReplacedTraits: soulImage.ReplacedTraits,
128133
})
129134

130-
if len(*soulImage.ReplacedTraits) == 0 { //only use the original replaced
135+
if len(*soulImage.ReplacedTraits) == 1 { //only use the original replaced
131136
wg3.Add(1)
132137
image := output[0].CapturedImage
133138
traits := output[0].Traits
@@ -147,7 +152,7 @@ func (u *Usecase) SoulNftImageCrontab() error {
147152
//send discord notification
148153
out.Nft.Image = image
149154
out.Nft.ImageCapture = image
150-
u.NewSoulTokenMintedNotify(&out.Nft)
155+
//u.NewSoulTokenMintedNotify(&out.Nft)
151156
}
152157
}
153158

@@ -160,7 +165,7 @@ func (u *Usecase) SoulNftImageCrontab() error {
160165
//load data for homepage
161166
wgPrepareData := sync.WaitGroup{}
162167
wgPrepareData.Add(1)
163-
go u.Repo.PrepareSoulData(&wgPrepareData)
168+
go u.Repo.PrepareSoulData(&wgPrepareData, tokenIDs)
164169
wgPrepareData.Wait()
165170

166171
page++
@@ -280,7 +285,7 @@ func (u *Usecase) SoulNftImageHistoriesCrontab(specialNfts []string) error {
280285

281286
wgPrepareData := sync.WaitGroup{}
282287
wgPrepareData.Add(1)
283-
go u.Repo.PrepareSoulData(&wgPrepareData)
288+
go u.Repo.PrepareSoulData(&wgPrepareData, tokenIDs)
284289
wgPrepareData.Wait()
285290

286291
page++

0 commit comments

Comments
 (0)