summaryrefslogtreecommitdiffstats
path: root/app/job.go
blob: 00439e4d2acebfca0d3feb8e1fc3bb782eeba56a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package app

import (
	"github.com/mattermost/platform/model"
)

func GetJobStatus(id string) (*model.JobStatus, *model.AppError) {
	if result := <-Srv.Store.JobStatus().Get(id); result.Err != nil {
		return nil, result.Err
	} else {
		return result.Data.(*model.JobStatus), nil
	}
}

func GetJobStatusesByTypePage(jobType string, page int, perPage int) ([]*model.JobStatus, *model.AppError) {
	return GetJobStatusesByType(jobType, page*perPage, perPage)
}

func GetJobStatusesByType(jobType string, offset int, limit int) ([]*model.JobStatus, *model.AppError) {
	if result := <-Srv.Store.JobStatus().GetAllByTypePage(jobType, offset, limit); result.Err != nil {
		return nil, result.Err
	} else {
		return result.Data.([]*model.JobStatus), nil
	}
}