mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost-server/model"
|
|
)
|
|
|
|
func (a *App) GetJob(id string) (*model.Job, *model.AppError) {
|
|
if result := <-a.Srv.Store.Job().Get(id); result.Err != nil {
|
|
return nil, result.Err
|
|
} else {
|
|
return result.Data.(*model.Job), nil
|
|
}
|
|
}
|
|
|
|
func (a *App) GetJobsPage(page int, perPage int) ([]*model.Job, *model.AppError) {
|
|
return a.GetJobs(page*perPage, perPage)
|
|
}
|
|
|
|
func (a *App) GetJobs(offset int, limit int) ([]*model.Job, *model.AppError) {
|
|
if result := <-a.Srv.Store.Job().GetAllPage(offset, limit); result.Err != nil {
|
|
return nil, result.Err
|
|
} else {
|
|
return result.Data.([]*model.Job), nil
|
|
}
|
|
}
|
|
|
|
func (a *App) GetJobsByTypePage(jobType string, page int, perPage int) ([]*model.Job, *model.AppError) {
|
|
return a.GetJobsByType(jobType, page*perPage, perPage)
|
|
}
|
|
|
|
func (a *App) GetJobsByType(jobType string, offset int, limit int) ([]*model.Job, *model.AppError) {
|
|
if result := <-a.Srv.Store.Job().GetAllByTypePage(jobType, offset, limit); result.Err != nil {
|
|
return nil, result.Err
|
|
} else {
|
|
return result.Data.([]*model.Job), nil
|
|
}
|
|
}
|
|
|
|
func (a *App) CreateJob(job *model.Job) (*model.Job, *model.AppError) {
|
|
return a.Jobs.CreateJob(job.Type, job.Data)
|
|
}
|
|
|
|
func (a *App) CancelJob(jobId string) *model.AppError {
|
|
return a.Jobs.RequestCancellation(jobId)
|
|
}
|