<commit_before>package server

import (
	"github.com/scootdev/scoot/common/thrifthelpers"
	s "github.com/scootdev/scoot/saga"
	"github.com/scootdev/scoot/sched"
	"github.com/scootdev/scoot/scootapi/gen-go/scoot"
	"github.com/scootdev/scoot/workerapi/gen-go/worker"
)

func GetJobStatus(jobId string, sc s.SagaCoordinator) (*scoot.JobStatus, error) {
	state, err := sc.GetSagaState(jobId)

	if err != nil {
		js := scoot.NewJobStatus()
		js.ID = ""
		js.Status = scoot.Status_NOT_STARTED

		if err != nil {
			switch err.(type) {
			case s.InvalidRequestError:
				err = scoot.NewInvalidRequest()
			case s.InternalLogError:
				err = scoot.NewScootServerError()
			}
		}

		return js, err
	}

	// No Logged Saga Messages.  Job NotStarted yet
	if state == nil {
		js := scoot.NewJobStatus()
		js.ID = jobId
		js.Status = scoot.Status_NOT_STARTED<commit_msg>scootapi/job_status - initialize TaskData and TaskStatus fields when job is not started (#239)<commit_after>package server

import (
	"github.com/scootdev/scoot/common/thrifthelpers"
	s "github.com/scootdev/scoot/saga"
	"github.com/scootdev/scoot/sched"
	"github.com/scootdev/scoot/scootapi/gen-go/scoot"
	"github.com/scootdev/scoot/workerapi/gen-go/worker"
)

func GetJobStatus(jobId string, sc s.SagaCoordinator) (*scoot.JobStatus, error) {
	state, err := sc.GetSagaState(jobId)

	if err != nil {
		js := scoot.NewJobStatus()
		js.ID = ""
		js.Status = scoot.Status_NOT_STARTED

		switch err.(type) {
		case s.InvalidRequestError:
			err = scoot.NewInvalidRequest()
		case s.InternalLogError:
			err = scoot.NewScootServerError()
		}

		return js, err
	}

	// No Logged Saga Messages.  Job NotStarted yet
	if state == nil {
		js := scoot.NewJobStatus()
		js.ID = jobId
		js.Status = scoot.Status_NOT_STARTED
		js.TaskStatus = make(map[string]scoot.Status)
		js.TaskData = make(map[string]*scoot.RunStatus)
{'fraction_non_alphanumeric': 0.1288244766505636, 'fraction_numerical': 0.001610305958132045, 'mean_word_length': 3.9182058047493404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686933', 'n_tokens_mistral': 773, 'n_tokens_neox': 716, 'n_words': 129}