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

192
Visualizações
NodeJS calculating difference between timestamps based on specific conditions

Have an interesting problem.

I have a SQL database, 50000+ entries containing data that looks as follows when queried with KnexJS:

[{
    id: 65532,
    status: 0.00,
    timestamp: 1656124205000,
  },
{
    id: 65533,
    status: 49.81,
    timestamp: 1656124503000,
  },
{
    id: 65534,
    status: 0.00,
    timestamp: 1656124909000,
  }
.... 60000+ more entries
]

I'm using Knex as the query builder.

I want be able to find every object where status is 0 and then get the following object where status is not 0 and then calculate the time difference for each occurrence where that happened.

Usually 0.00 won't be consecutive, but there's no guarantee for that, else I would've just grabbed the id/index where status is 0.00 and + 1.

Any suggestions where to get started with this kinda logic?

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