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
928a987b
Commit
928a987b
authored
Jan 14, 2025
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize SQL query
parent
cc651198
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
11 deletions
+17
-11
db.go
dao/db.go
+1
-5
task.go
server/task.go
+13
-3
group.go
service/group.go
+1
-1
task.go
service/task.go
+2
-2
No files found.
dao/db.go
View file @
928a987b
...
@@ -136,11 +136,7 @@ func (d *Dao) IsTaskDone(tid int, userId string) (ok bool, err error) {
...
@@ -136,11 +136,7 @@ func (d *Dao) IsTaskDone(tid int, userId string) (ok bool, err error) {
return
count
>
0
,
err
return
count
>
0
,
err
}
}
func
(
d
*
Dao
)
GetTaskResult
(
tid
int
,
userId
string
)
(
status
string
,
submittedAt
time
.
Time
,
err
error
)
{
func
(
d
*
Dao
)
GetTaskResult
(
isDailyTask
bool
,
tid
int
,
userId
string
)
(
status
string
,
submittedAt
time
.
Time
,
err
error
)
{
isDailyTask
,
err
:=
d
.
IsDailyTask
(
tid
)
if
err
!=
nil
{
return
""
,
time
.
Time
{},
err
}
temp
:=
&
dbModel
.
TaskHistory
{}
temp
:=
&
dbModel
.
TaskHistory
{}
tx
:=
d
.
db
.
Session
(
&
gorm
.
Session
{
Logger
:
logger
.
Default
.
LogMode
(
logger
.
Silent
)})
tx
:=
d
.
db
.
Session
(
&
gorm
.
Session
{
Logger
:
logger
.
Default
.
LogMode
(
logger
.
Silent
)})
if
!
isDailyTask
{
if
!
isDailyTask
{
...
...
server/task.go
View file @
928a987b
...
@@ -79,7 +79,18 @@ func checkTask(c *gin.Context) {
...
@@ -79,7 +79,18 @@ func checkTask(c *gin.Context) {
return
return
}
}
status
,
_
,
err
:=
srv
.
GetTaskResult
(
taskId
,
userId
)
task
,
err
:=
srv
.
GetTaskDetail
(
taskId
)
if
err
!=
nil
{
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
return
}
if
task
==
nil
{
c
.
JSON
(
200
,
withError
(
"task not found"
))
return
}
status
,
_
,
err
:=
srv
.
GetTaskResult
(
task
.
Daily
,
taskId
,
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
return
return
...
@@ -116,8 +127,7 @@ func submitTask(c *gin.Context) {
...
@@ -116,8 +127,7 @@ func submitTask(c *gin.Context) {
c
.
JSON
(
200
,
withError
(
"task not found"
))
c
.
JSON
(
200
,
withError
(
"task not found"
))
return
return
}
}
status
,
_
,
err
:=
srv
.
GetTaskResult
(
task
.
Daily
,
taskId
,
userId
)
status
,
_
,
err
:=
srv
.
GetTaskResult
(
taskId
,
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
return
return
...
...
service/group.go
View file @
928a987b
...
@@ -74,7 +74,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
...
@@ -74,7 +74,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
Enable
:
task
.
Enable
,
Enable
:
task
.
Enable
,
}
}
status
,
submittedAt
,
err
:=
s
.
GetTaskResult
(
_task
.
TaskId
.
(
int
),
userId
)
status
,
submittedAt
,
err
:=
s
.
GetTaskResult
(
_task
.
Daily
,
_task
.
TaskId
.
(
int
),
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"group check task"
)
log
.
WithError
(
err
)
.
Error
(
"group check task"
)
return
nil
,
err
return
nil
,
err
...
...
service/task.go
View file @
928a987b
...
@@ -149,8 +149,8 @@ func (s *Service) GetTaskDetail(taskId int) (task *dbModel.Task, err error) {
...
@@ -149,8 +149,8 @@ func (s *Service) GetTaskDetail(taskId int) (task *dbModel.Task, err error) {
return
return
}
}
func
(
s
*
Service
)
GetTaskResult
(
taskId
int
,
userId
string
)
(
status
string
,
submittedAt
time
.
Time
,
err
error
)
{
func
(
s
*
Service
)
GetTaskResult
(
isDailyTask
bool
,
taskId
int
,
userId
string
)
(
status
string
,
submittedAt
time
.
Time
,
err
error
)
{
status
,
submittedAt
,
err
=
s
.
d
.
GetTaskResult
(
taskId
,
userId
)
status
,
submittedAt
,
err
=
s
.
d
.
GetTaskResult
(
isDailyTask
,
taskId
,
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"get task result error"
)
log
.
WithError
(
err
)
.
Error
(
"get task result error"
)
}
}
...
...
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