import RepoSyncState from "../models/reposyncstate" ; import sqsQueues from "../sqs/queues" ; import Subscription from "../models/subscription" ; import { LoggerWithTarget } from "probot/lib/wrap-logger" ; import Logger from 'bunyan' ; export async function findOrStartSync ( subscription , logger , syncType ? ) { const { gitHubInstallationId : installationId , jiraHost } = subscription ; const count = await RepoSyncState . countFromSubscription ( subscription ) ; if ( count === 0 || syncType === "full" ) { await RepoSyncState . resetSyncFromSubscription ( subscription ) ; logger . info ( "Starting Jira sync" ) ; await sqsQueues . discovery . sendMessage ( { installationId , jiraHost } , 0 , logger ) ; return ; } await sqsQueues . backfill . sendMessage ( { installationId , jiraHost } , 0 , logger ) ; }