@@ -116,13 +116,14 @@ func InitScraper() {
116116 })
117117}
118118
119- func createTask (clientIP , region , taskType string , query map [string ]string ) (taskAdded , tasksQuantityExceeded bool ) {
119+ func createTask (clientIP , region , taskType string , query map [string ]string ) (ok , tasksExceeded bool , tasksNumber int ) {
120120 crc32 := crc32 .NewIEEE ()
121121 crc32 .Write ([]byte (strings .Join (append (slices .Sorted (maps .Values (query )), region , taskType ), "" )))
122122 hashString := strconv .Itoa (int (crc32 .Sum32 ()))
123123
124- if taskQueue .CountQueuedTasksForClient (clientIP ) >= viper .GetInt ("maxtasksperclient" ) {
125- return false , true
124+ tasksN := taskQueue .CountQueuedTasksForClient (clientIP )
125+ if tasksN >= viper .GetInt ("maxtasksperclient" ) {
126+ return false , true , tasksN
126127 }
127128
128129 url := fmt .Sprintf (
@@ -147,17 +148,17 @@ func createTask(clientIP, region, taskType string, query map[string]string) (tas
147148 "taskType" : taskType ,
148149 })
149150
150- added : = taskQueue .AddTask (clientIP , hashString , utils .BuildRequest (url , query ))
151- return added , false
151+ ok = taskQueue .AddTask (clientIP , hashString , utils .BuildRequest (url , query ))
152+ return ok , false , map [ bool ] int { true : tasksN + 1 , false : tasksN }[ ok ]
152153}
153154
154- func EnqueueAdventurer (clientIP , region , profileTarget string ) (taskAdded , tasksQuantityExceeded bool ) {
155+ func EnqueueAdventurer (clientIP , region , profileTarget string ) (ok , tasksExceeded bool , tasksNumber int ) {
155156 return createTask (clientIP , region , "player" , map [string ]string {
156157 "profileTarget" : profileTarget ,
157158 })
158159}
159160
160- func EnqueueAdventurerSearch (clientIP , region , query , searchType string ) (taskAdded , tasksQuantityExceeded bool ) {
161+ func EnqueueAdventurerSearch (clientIP , region , query , searchType string ) (ok , tasksExceeded bool , tasksNumber int ) {
161162 return createTask (clientIP , region , "playerSearch" , map [string ]string {
162163 "Page" : "1" ,
163164 "region" : region ,
@@ -166,14 +167,14 @@ func EnqueueAdventurerSearch(clientIP, region, query, searchType string) (taskAd
166167 })
167168}
168169
169- func EnqueueGuild (clientIP , region , name string ) (taskAdded , tasksQuantityExceeded bool ) {
170+ func EnqueueGuild (clientIP , region , name string ) (ok , tasksExceeded bool , tasksNumber int ) {
170171 return createTask (clientIP , region , "guild" , map [string ]string {
171172 "guildName" : name ,
172173 "region" : region ,
173174 })
174175}
175176
176- func EnqueueGuildSearch (clientIP , region , query string ) (taskAdded , tasksQuantityExceeded bool ) {
177+ func EnqueueGuildSearch (clientIP , region , query string ) (ok , tasksExceeded bool , tasksNumber int ) {
177178 return createTask (clientIP , region , "guildSearch" , map [string ]string {
178179 "page" : "1" ,
179180 "region" : region ,
0 commit comments