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
3f0370ec
Commit
3f0370ec
authored
Jan 13, 2025
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add task pass option
parent
6f3e597c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
21 deletions
+24
-21
taskcenter.go
model/db/taskcenter.go
+1
-0
task.go
sync/task.go
+23
-21
No files found.
model/db/taskcenter.go
View file @
3f0370ec
...
@@ -80,6 +80,7 @@ type Task struct {
...
@@ -80,6 +80,7 @@ type Task struct {
Start
int
`gorm:"type:int;not null;comment:任务开始时间"`
Start
int
`gorm:"type:int;not null;comment:任务开始时间"`
End
int
`gorm:"type:int;index;not null;comment:任务结束时间"`
End
int
`gorm:"type:int;index;not null;comment:任务结束时间"`
Daily
bool
`gorm:"type:bool;not null;comment:是否是每日任务"`
Daily
bool
`gorm:"type:bool;not null;comment:是否是每日任务"`
Pass
bool
`gorm:"type:bool;not null;comment:是否跳过检查"`
TwitterTaskEndAt
sql
.
NullTime
`gorm:"index;comment:推特可用,推特任务中心已停止"`
TwitterTaskEndAt
sql
.
NullTime
`gorm:"index;comment:推特可用,推特任务中心已停止"`
TelegramActiveThreshold
int
`gorm:"type:int;not null;comment:telegram群活跃阈值"`
TelegramActiveThreshold
int
`gorm:"type:int;not null;comment:telegram群活跃阈值"`
Enable
bool
`gorm:"type:bool;not null;comment:是否启用"`
Enable
bool
`gorm:"type:bool;not null;comment:是否启用"`
...
...
sync/task.go
View file @
3f0370ec
...
@@ -12,29 +12,26 @@ func (s *Sync) ProcessTasks() {
...
@@ -12,29 +12,26 @@ func (s *Sync) ProcessTasks() {
ticker
:=
time
.
NewTicker
(
time
.
Second
)
ticker
:=
time
.
NewTicker
(
time
.
Second
)
defer
ticker
.
Stop
()
defer
ticker
.
Stop
()
log
.
Info
(
"start sync task"
)
log
.
Info
(
"start sync task"
)
for
{
for
range
ticker
.
C
{
select
{
tasks
,
err
:=
s
.
d
.
GetUnprocessedTasks
()
case
<-
ticker
.
C
:
if
err
!=
nil
{
tasks
,
err
:=
s
.
d
.
GetUnprocessedTasks
()
log
.
WithError
(
err
)
.
Error
(
"get unprocessed tasks error"
)
return
}
for
_
,
task
:=
range
tasks
{
status
:=
constant
.
TaskHistoryStatusSuccess
ok
,
err
:=
s
.
SyncTask
(
task
.
TaskId
,
task
.
UserId
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"get unprocessed tasks error"
)
log
.
WithError
(
err
)
.
Error
(
"sync task error"
)
return
}
}
if
!
ok
{
for
_
,
task
:=
range
tasks
{
status
=
constant
.
TaskHistoryStatusRetry
status
:=
constant
.
TaskHistoryStatusSuccess
}
ok
,
err
:=
s
.
SyncTask
(
task
.
TaskId
,
task
.
UserId
)
log
.
WithFields
(
log
.
Fields
{
"task_id"
:
task
.
Id
,
"error"
:
err
,
"status"
:
status
})
.
Info
(
"sync task"
)
if
err
!=
nil
{
err
=
s
.
d
.
UpdateTaskHistory
(
task
.
Id
,
status
)
log
.
WithError
(
err
)
.
Error
(
"sync task error"
)
if
err
!=
nil
{
}
log
.
WithError
(
err
)
.
Error
(
"update task history error"
)
if
!
ok
{
status
=
constant
.
TaskHistoryStatusRetry
}
log
.
WithFields
(
log
.
Fields
{
"task_id"
:
task
.
Id
,
"error"
:
err
,
"status"
:
status
})
.
Info
(
"sync task"
)
err
=
s
.
d
.
UpdateTaskHistory
(
task
.
Id
,
status
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"update task history error"
)
}
}
}
}
}
}
}
...
@@ -51,6 +48,11 @@ func (s *Sync) SyncTask(taskId int, userId string) (ok bool, err error) {
...
@@ -51,6 +48,11 @@ func (s *Sync) SyncTask(taskId int, userId string) (ok bool, err error) {
return
return
}
}
if
task
.
Pass
{
log
.
WithFields
(
log
.
Fields
{
"task_id"
:
taskId
,
"user_id"
:
userId
})
.
Info
(
"task pass"
)
return
true
,
nil
}
switch
task
.
Platform
{
switch
task
.
Platform
{
case
constant
.
TaskPlatformTelegram
:
case
constant
.
TaskPlatformTelegram
:
telegramUserId
,
err
:=
s
.
d
.
GetProviderId
(
userId
,
constant
.
TaskPlatformTelegram
)
telegramUserId
,
err
:=
s
.
d
.
GetProviderId
(
userId
,
constant
.
TaskPlatformTelegram
)
...
...
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