Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskcenter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
taskcenter
Commits
b1097bf5
Commit
b1097bf5
authored
Jan 14, 2025
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update parallel query
parent
928a987b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
27 deletions
+37
-27
task.go
server/task.go
+0
-2
group.go
service/group.go
+37
-25
No files found.
server/task.go
View file @
b1097bf5
...
...
@@ -189,6 +189,4 @@ func submitTask(c *gin.Context) {
return
}
c
.
JSON
(
200
,
withSuccess
(
gin
.
H
{}))
return
}
service/group.go
View file @
b1097bf5
package
service
import
(
"sync"
"taskcenter/constant"
apiModel
"taskcenter/model/api"
dbModel
"taskcenter/model/db"
...
...
@@ -59,33 +60,44 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
return
}
for
_
,
task
:=
range
tasks
{
_task
:=
apiModel
.
Task
{
TaskId
:
task
.
Id
,
Platform
:
task
.
Platform
,
Action
:
task
.
Action
,
Url
:
task
.
Url
,
Description
:
task
.
Description
,
Reward
:
task
.
Reward
,
Start
:
task
.
Start
,
End
:
task
.
End
,
Daily
:
task
.
Daily
,
TweetId
:
task
.
TweetId
,
Enable
:
task
.
Enable
,
}
taskResults
:=
make
([]
apiModel
.
Task
,
len
(
tasks
))
var
wg
sync
.
WaitGroup
status
,
submittedAt
,
err
:=
s
.
GetTaskResult
(
_task
.
Daily
,
_task
.
TaskId
.
(
int
),
userId
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"group check task"
)
return
nil
,
err
}
_task
.
Status
=
status
if
status
==
constant
.
TaskHistoryStatusRetry
{
_task
.
Msg
=
"The task is not completed, please try again."
}
_task
.
SubmitTimestamp
=
int
(
submittedAt
.
Unix
())
resp
.
Tasks
=
append
(
resp
.
Tasks
,
_task
)
for
i
:=
range
tasks
{
wg
.
Add
(
1
)
go
func
(
idx
int
)
{
defer
wg
.
Done
()
task
:=
tasks
[
idx
]
_task
:=
apiModel
.
Task
{
TaskId
:
task
.
Id
,
Platform
:
task
.
Platform
,
Action
:
task
.
Action
,
Url
:
task
.
Url
,
Description
:
task
.
Description
,
Reward
:
task
.
Reward
,
Start
:
task
.
Start
,
End
:
task
.
End
,
Daily
:
task
.
Daily
,
TweetId
:
task
.
TweetId
,
Enable
:
task
.
Enable
,
}
status
,
submittedAt
,
err
:=
s
.
GetTaskResult
(
_task
.
Daily
,
_task
.
TaskId
.
(
int
),
userId
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"group check task"
)
return
}
_task
.
Status
=
status
if
status
==
constant
.
TaskHistoryStatusRetry
{
_task
.
Msg
=
"The task is not completed, please try again."
}
_task
.
SubmitTimestamp
=
int
(
submittedAt
.
Unix
())
taskResults
[
idx
]
=
_task
}(
i
)
}
wg
.
Wait
()
resp
.
Tasks
=
taskResults
return
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment