hunk.code_window: check-server-style: govet
   	@echo Running GOFMT
   	$(eval GOFMT_OUTPUT := $(shell gofmt -d -s api/ model/ store/ utils/ manualtesting/ einterfaces/ cmd/platform/ 2>&1))
   	@echo "$(GOFMT_OUTPUT)"
   	@if [ ! "$(GOFMT_OUTPUT)" ]; then \
   		echo "gofmt success"; \
   	else \
   		echo "gofmt failure"; \
   		exit 1; \
   	fi
   check-style: check-client-style check-server-style
  
hunk.labels: keep keep keep replace replace replace replace replace replace replace replace keep keep keep
hunk.after_edit: 	@for package in $(TE_PACKAGES) $(EE_PACKAGES); do \
   		echo "Checking "$$package; \
   		files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \
   		if [ "$$files" ]; then \
   			gofmt_output=$$(gofmt -d -s $$files 2>&1); \
   			if [ "$$gofmt_output" ]; then \
   				echo "$$gofmt_output"; \
   				echo "gofmt failure"; \
   				exit 1; \
   			fi; \
   		fi; \
   	done
   	@echo "gofmt success"; \
  
hunk.file_path: Makefile
hunk.type: replace
file: // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
  // See License.txt for license information.
  
  package app
  
  import (
  	"github.com/mattermost/platform/model"
  	"github.com/mattermost/platform/jobs"
  )
  
  func GetJob(id string) (*model.Job, *model.AppError) {
  	if result := <-Srv.Store.Job().Get(id); result.Err != nil {
  		return nil, result.Err
  	} else {
  		return result.Data.(*model.Job), nil
  	}
  }
  
  func GetJobsPage(page int, perPage int) ([]*model.Job, *model.AppError) {
  	return GetJobs(page*perPage, perPage)
  }
  
  func GetJobs(offset int, limit int) ([]*model.Job, *model.AppError) {
  	if result := <-Srv.Store.Job().GetAllPage(offset, limit); result.Err != nil {
  		return nil, result.Err
  	} else {
  		return result.Data.([]*model.Job), nil
  	}
  }
  
  func GetJobsByTypePage(jobType string, page int, perPage int) ([]*model.Job, *model.AppError) {
  	return GetJobsByType(jobType, page*perPage, perPage)
  }
  
  func GetJobsByType(jobType string, offset int, limit int) ([]*model.Job, *model.AppError) {
  	if result := <-Srv.Store.Job().GetAllByTypePage(jobType, offset, limit); result.Err != nil {
  		return nil, result.Err
  	} else {
  		return result.Data.([]*model.Job), nil
  	}
  }
  
  func CreateJob(job *model.Job) (*model.Job, *model.AppError) {
  	return jobs.CreateJob(job.Type, job.Data)
  }
  
  func CancelJob(jobId string) *model.AppError {
  	return jobs.RequestCancellation(jobId)
  }
  