Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/boxes?date= returns nothing #107

Open
noerw opened this issue Aug 15, 2017 · 2 comments
Open

/boxes?date= returns nothing #107

noerw opened this issue Aug 15, 2017 · 2 comments
Labels

Comments

@noerw
Copy link
Member

noerw commented Aug 15, 2017

https://api.opensensemap.org/boxes?date=2017-08-06T00:00:00Z,2017-08-10T12:49:51Z

@noerw noerw added the bug label Aug 15, 2017
@noerw
Copy link
Member Author

noerw commented Aug 24, 2017

sometimes an empty response is returned, sometimes

{"code":"InternalServerError","message":"connection 16 to 172.31.46.193:27017 timed out"}

@ubergesundheit
Copy link
Member

Seems the aggregation executed when requesting the route with date parameters does not receive data in time thus timing out. (

execStreamBoxesToClientPromise = Measurement.aggregate([
{
$match: {
createdAt: {
'$gt': fromDate.toDate(),
'$lt': toDate.toDate()
}
}
},
{
$group: {
_id: '$sensor_id',
value: { $first: '$value' },
createdAt: { $first: '$createdAt' },
sensor_id: { $first: '$sensor_id' }
},
},
{ $project: { value: 1, createdAt: 1, sensor_id: 1, _id: 0 } }
])
)

I have no particular plans, but in the long run I have to think about speeding up the aggregation or using some trick to cache the information if there is data for a particular timeframe or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants