Code Monkey home page Code Monkey logo

Comments (1)

caparker avatar caparker commented on September 14, 2024

This happens when a user requests data for a one period, e.g. 2020-10-20 -> 2022-11-21 and there is data but its for a period of time that ends prior to the start date requested.
Because the following section is replacing the users requested start date with the last recorded datetime

date_to = min(
date_to, range_end, datetime.utcnow().replace(tzinfo=UTC)
)

This results in an end date that is before the start date, which leads to a negative count of seconds for the duration which then leads to a negative count of total measurements. The following sections show the calculation of seconds and then how its used to get the (estimated?) total count.

dq = float((date_to - date_from).total_seconds()) # duration of query

count = int(total_count * dq / dd)

A fix to this might simply be to add the requested start/end times to the initial query here

from openaq-api-v2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.