Comments (8)
from air-quality-web.
Thanks for opening a new issue about this. Sorry I didn't reply, I've been busy (both with PhD work, and sorting out the disclaimer on here).
I'll take a look into this.
Edit: Do you have that as a curl
command? That would be much easier for me to test with
from air-quality-web.
For my own reference the above can be represented with curl
like so:
curl 'http://[::1]:40482/api.php?action=list-devices-near&count=5' --data "latitude=53.750" --data "longitude=-0.395" | jq .
from air-quality-web.
With some investigation, it would seem that the SQL query is at fault...... somehow. Here's the SQL query for that api call:
SELECT
devices.device_id AS id,
devices.device_name AS name,
devices.device_latitude AS latitude,
devices.device_longitude AS longitude,
ST_DISTANCE_SPHERE(POINT(53.750, -0.395), devices.lat_lon) AS distance_calc, devices.last_seen AS last_seen
FROM devices
JOIN readings ON readings.device_id = devices.device_id
WHERE devices.lat_lon IS NOT NULL
ORDER BY ST_DISTANCE_SPHERE(POINT(53.750, -0.395), devices.lat_lon)
LIMIT 5;
I'm somewhat baffled as to what it's suddenly generating duplicates. Thoughts?
/cc @BNNorman
from air-quality-web.
duplicates normally arise if you don't use a right join
from air-quality-web.
I know it once worked, we/you altered it.
I then asked for last seen and the commit a678a89a was made.
I cannot remember if I tested if that worked, or if that brought in the last problem (server error), that was then fixed.
Just checking you are using the current beta server as the fix was never release to the live server. At least for normal users.
as for time, same problem here. reporting things between everything else when I drop in and have a go at using it :-)
from air-quality-web.
Ah, I see @BNNorman. If I change the query to this though:
SELECT
devices.device_id AS id,
devices.device_name AS name,
devices.device_latitude AS latitude,
devices.device_longitude AS longitude,
ST_DISTANCE_SPHERE(POINT(53.750, -0.395), devices.lat_lon) AS distance_calc, devices.last_seen AS last_seen
FROM devices
RIGHT JOIN readings ON readings.device_id = devices.device_id
WHERE devices.lat_lon IS NOT NULL
ORDER BY ST_DISTANCE_SPHERE(POINT(53.750, -0.395), devices.lat_lon)
LIMIT 5;
...I still get the same result:
+----+----------------+-------------+-------------+-------------------+---------------------+
| id | name | latitude | longitude | distance_calc | last_seen |
+----+----------------+-------------+-------------+-------------------+---------------------+
| 36 | CHASW-24AD43-1 | 53.75642593 | -0.36844245 | 1886.588853560329 | 2020-05-01 22:09:46 |
| 36 | CHASW-24AD43-1 | 53.75642593 | -0.36844245 | 1886.588853560329 | 2020-05-01 22:09:46 |
| 36 | CHASW-24AD43-1 | 53.75642593 | -0.36844245 | 1886.588853560329 | 2020-05-01 22:09:46 |
| 36 | CHASW-24AD43-1 | 53.75642593 | -0.36844245 | 1886.588853560329 | 2020-05-01 22:09:46 |
| 36 | CHASW-24AD43-1 | 53.75642593 | -0.36844245 | 1886.588853560329 | 2020-05-01 22:09:46 |
+----+----------------+-------------+-------------+-------------------+---------------------+
...even though I'm specifying a right join explicitly.
@bsimmo: This is using a local development server that's running the latest from the dev
branch.
Hrm. You're saying that this is a regression and it worked before? Thanks for that commit id - that;s really helpful for narrowing down what's gone wrong. I'm pretty sure the problematic change is in a678a89#diff-de7016366166fa0b532d03d624168e27R151-R176.
Thinking about it, I'm not even sure why we're joining there in the first place, since it would appear that the only time the readings
table is referenced is in the join itself. If I do this instead:
SELECT
devices.device_id AS id,
devices.device_name AS name,
devices.device_latitude AS latitude,
devices.device_longitude AS longitude,
ST_DISTANCE_SPHERE(POINT(53.750, -0.395), devices.lat_lon) AS distance_calc, devices.last_seen AS last_seen
FROM devices
WHERE devices.lat_lon IS NOT NULL
ORDER BY ST_DISTANCE_SPHERE(POINT(53.750, -0.395), devices.lat_lon)
LIMIT 5;
...then I correctly get this:
+----+------------------+-------------+-------------+--------------------+---------------------+
| id | name | latitude | longitude | distance_calc | last_seen |
+----+------------------+-------------+-------------+--------------------+---------------------+
| 36 | CHASW-24AD43-1 | 53.75642593 | -0.36844245 | 1886.588853560329 | 2020-05-01 22:15:46 |
| 32 | CHASW-56AB6D-1 | 53.767262 | -0.403431 | 1997.8605170536607 | 2020-05-01 06:00:56 |
| 51 | CL-AW15CH6N | 53.7432075 | -0.3586957 | 2503.8574249443122 | 2020-03-12 23:00:00 |
| 35 | CHASR-6F3BD82C-1 | 53.75776 | -0.436268 | 2847.053372632466 | 2020-05-01 22:17:15 |
| 48 | HCCSENSOR03 | 53.739378 | -0.34838408 | 3285.0856113502487 | 2020-05-01 22:16:51 |
+----+------------------+-------------+-------------+--------------------+---------------------+
...does this look right to everyone? Have I missed something? I can't remember what I was thinking at the time, and the commit message doesn't give anything away. I feel like I'm missing something.
If this altered SQL query looks ok, I'll go ahead and patch the SQL query by removing the JOIN
altogether.
from air-quality-web.
Fixed - at least for me. Should land in beta in ~20 mins
from air-quality-web.
Related Issues (20)
- Display the currently selected reading type on the heatmap when loading the device graph HOT 1
- Migration: Slow HTTP API calls HOT 9
- When clicking sensors on the AQ Map (sometimes) the map just zooms HOT 5
- Sensor filter HOT 12
- Mosquitto stuck Address in use (1883) HOT 3
- FTW says 6 hours ago but last reading was 12:00 (now 16:00) HOT 13
- Issue with web site on some devices HOT 22
- Repeated measurement types above chart HOT 5
- Can the charts be made to open with data rather than just say error: no data recorded HOT 1
- Slow charts HOT 5
- POST request : Error 500 Internal Server Error HOT 7
- device.visible has no effect on the map HOT 7
- API and documents not working HOT 3
- Circles, on Opening the Map, don't disappear HOT 2
- Sensor not showing up correctly on current (0.14-dev) beta site HOT 5
- Last seen on chart is wrong HOT 6
- Wrong base URL in the API docs HOT 1
- graph not showing data for device bonus-a-abp HOT 5
- Integration with custom sensors and visual optimizations ? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from air-quality-web.