github.com/vnforks/kid/v5@v5.22.1-0.20200408055009-b89d99c65676/app/job.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package app 5 6 import ( 7 "github.com/vnforks/kid/v5/model" 8 ) 9 10 func (a *App) GetJob(id string) (*model.Job, *model.AppError) { 11 return a.Srv().Store.Job().Get(id) 12 } 13 14 func (a *App) GetJobsPage(page int, perPage int) ([]*model.Job, *model.AppError) { 15 return a.GetJobs(page*perPage, perPage) 16 } 17 18 func (a *App) GetJobs(offset int, limit int) ([]*model.Job, *model.AppError) { 19 return a.Srv().Store.Job().GetAllPage(offset, limit) 20 } 21 22 func (a *App) GetJobsByTypePage(jobType string, page int, perPage int) ([]*model.Job, *model.AppError) { 23 return a.GetJobsByType(jobType, page*perPage, perPage) 24 } 25 26 func (a *App) GetJobsByType(jobType string, offset int, limit int) ([]*model.Job, *model.AppError) { 27 return a.Srv().Store.Job().GetAllByTypePage(jobType, offset, limit) 28 } 29 30 func (a *App) CreateJob(job *model.Job) (*model.Job, *model.AppError) { 31 return a.Srv().Jobs.CreateJob(job.Type, job.Data) 32 } 33 34 func (a *App) CancelJob(jobId string) *model.AppError { 35 return a.Srv().Jobs.RequestCancellation(jobId) 36 }