1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-07 12:30:06 +00:00

fix(job-status): print job status only if it changes

This commit is contained in:
Yury Shkoda
2021-01-11 13:52:38 +03:00
parent b23f199334
commit 5a2ee88cbc

View File

@@ -1107,6 +1107,8 @@ export class SASViyaApiClient {
} }
return new Promise(async (resolve, _) => { return new Promise(async (resolve, _) => {
let printedState = ''
const interval = setInterval(async () => { const interval = setInterval(async () => {
if ( if (
postedJobState === 'running' || postedJobState === 'running' ||
@@ -1114,9 +1116,6 @@ export class SASViyaApiClient {
postedJobState === 'pending' postedJobState === 'pending'
) { ) {
if (stateLink) { if (stateLink) {
if (this.debug) {
console.log('Polling job status... \n')
}
const { result: jobState } = await this.request<string>( const { result: jobState } = await this.request<string>(
`${this.serverUrl}${stateLink.href}?_action=wait&wait=30`, `${this.serverUrl}${stateLink.href}?_action=wait&wait=30`,
{ {
@@ -1126,10 +1125,16 @@ export class SASViyaApiClient {
) )
postedJobState = jobState.trim() postedJobState = jobState.trim()
if (this.debug) {
if (this.debug && postedJobState !== printedState) {
console.log('Polling job status... \n')
console.log(`Current state: ${postedJobState}\n`) console.log(`Current state: ${postedJobState}\n`)
printedState = postedJobState
} }
pollCount++ pollCount++
if (pollCount >= MAX_POLL_COUNT) { if (pollCount >= MAX_POLL_COUNT) {
resolve(postedJobState) resolve(postedJobState)
} }