62886dbba8
Remove Job * removejob * rmjob * sync * cleanup * precommit * startslow * startslow * startslow * openapi * clean * test * scripts * littlecleanercmds * mermaid
36 lines
706 B
Go
36 lines
706 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"queryorchestration/internal/database"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Status string
|
|
|
|
const (
|
|
NOT_SYNCED Status = "not_synced"
|
|
NOT_SYNCING Status = "not_syncing"
|
|
IN_SYNC Status = "in_sync"
|
|
)
|
|
|
|
func (s *Service) GetStatus(ctx context.Context, id uuid.UUID) (Status, error) {
|
|
client, err := s.cfg.GetDBQueries().GetClient(ctx, database.MustToDBUUID(id))
|
|
if err != nil {
|
|
return NOT_SYNCING, err
|
|
} else if !client.Cansync {
|
|
return NOT_SYNCING, nil
|
|
}
|
|
|
|
issynced, err := s.cfg.GetDBQueries().IsClientSynced(ctx, database.MustToDBUUID(id))
|
|
if err != nil {
|
|
return NOT_SYNCING, err
|
|
} else if issynced {
|
|
return IN_SYNC, nil
|
|
}
|
|
|
|
return NOT_SYNCED, nil
|
|
}
|