mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
feat(schedule): add name and allow disable
This commit is contained in:
parent
aca9055abb
commit
8fe600fd4f
@ -774,6 +774,10 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
template_id:
|
template_id:
|
||||||
type: integer
|
type: integer
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
disabled:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
Schedule:
|
Schedule:
|
||||||
type: object
|
type: object
|
||||||
@ -786,6 +790,10 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
template_id:
|
template_id:
|
||||||
type: integer
|
type: integer
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
disabled:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
ViewRequest:
|
ViewRequest:
|
||||||
type: object
|
type: object
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
type Schedule struct {
|
type Schedule struct {
|
||||||
ID int `db:"id" json:"id"`
|
ID int `db:"id" json:"id"`
|
||||||
ProjectID int `db:"project_id" json:"project_id"`
|
ProjectID int `db:"project_id" json:"project_id"`
|
||||||
TemplateID int `db:"template_id" json:"template_id"`
|
TemplateID int `db:"template_id" json:"template_id"`
|
||||||
CronFormat string `db:"cron_format" json:"cron_format"`
|
CronFormat string `db:"cron_format" json:"cron_format"`
|
||||||
RepositoryID *int `db:"repository_id" json:"repository_id"`
|
Name string `db:"name" json:"name"`
|
||||||
|
Disabled bool `db:"disabled" json:"disabled"`
|
||||||
|
|
||||||
LastCommitHash *string `db:"last_commit_hash" json:"-"`
|
LastCommitHash *string `db:"last_commit_hash" json:"-"`
|
||||||
|
RepositoryID *int `db:"repository_id" json:"repository_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScheduleWithTpl struct {
|
type ScheduleWithTpl struct {
|
||||||
|
@ -1 +1,3 @@
|
|||||||
alter table `project__template` add `tasks` int not null default 0;
|
alter table `project__template` add `tasks` int not null default 0;
|
||||||
|
alter table `project__schedule` add `name` varchar(100);
|
||||||
|
alter table `project__schedule` add `disabled` boolean not null default false;
|
@ -4,11 +4,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/ansible-semaphore/semaphore/db"
|
"github.com/ansible-semaphore/semaphore/db"
|
||||||
"github.com/ansible-semaphore/semaphore/db_lib"
|
"github.com/ansible-semaphore/semaphore/db_lib"
|
||||||
"github.com/ansible-semaphore/semaphore/services/tasks"
|
"github.com/ansible-semaphore/semaphore/services/tasks"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScheduleRunner struct {
|
type ScheduleRunner struct {
|
||||||
@ -111,6 +111,10 @@ func (p *SchedulePool) Refresh() {
|
|||||||
p.locker.Lock()
|
p.locker.Lock()
|
||||||
p.clear()
|
p.clear()
|
||||||
for _, schedule := range schedules {
|
for _, schedule := range schedules {
|
||||||
|
if schedule.Disabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
_, err := p.addRunner(ScheduleRunner{
|
_, err := p.addRunner(ScheduleRunner{
|
||||||
projectID: schedule.ProjectID,
|
projectID: schedule.ProjectID,
|
||||||
scheduleID: schedule.ID,
|
scheduleID: schedule.ID,
|
||||||
|
Loading…
Reference in New Issue
Block a user