Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Improving performance in a Nest JS service

I developed a service with Nest JS which calls a third party api in order to get the status related to some pull requests in Azure DevOps. The logic works as follows: I provide an array with links to a function, then I use a for loop to a block of code which will take care of getting the url from the array and build the http request and call the api to retrieve the status(using the axios implementation in Nest JS). It works as an async operation which sequentially makes each request. But it is taking relatively too long(about 160s to get 1000 requests). Does someone have a suggestion in how to improve the speed of execution?

async getAzureStatus(urlAdjusted) {
        const updatedPRStatus = [process.env.EXCEL_COLUMN_PR_STATUS_HEADER];
        
        for(let counter = 1; counter < urlAdjusted.length; counter++) {
            if( urlAdjusted[counter] == 'Not needed')
            {
                updatedPRStatus.push('Not needed');
            }
            else
            {
                const config =
                {
                    headers:
                    {
                        Authorization: process.env.AUTHENTICATION_KEY,
                    },
                };
                try 
                {
                    const response = await lastValueFrom(this.httpService.get(urlAdjusted[counter], config));
                    updatedPRStatus.push(response.data['status']);
                } catch(error) 
                {
                    console.log('error retrieving pr number ' + counter );
                    updatedPRStatus.push('Could not get any data');
                }
            } 
        }
        
        return updatedPRStatus;
    }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda