mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-25 06:53:00 +00:00
Round dates when making heatmap api requests
This commit is contained in:
parent
2a65f223c1
commit
5ef5cec040
4 changed files with 27 additions and 2 deletions
|
@ -1,13 +1,15 @@
|
||||||
The data displayed has been produced by low-cost devices developed by [Connected Humber](https://www.connectedhumber.org/) members as part of a community driven effort to build a network of smart sensors in the Humber Region.
|
The data displayed has been produced by low-cost devices developed by [Connected Humber](https://www.connectedhumber.org/) members as part of a community driven effort to build a network of smart sensors in the Humber Region.
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
|
||||||
This is the changelog for the air quality web interface and its associated HTTP API.
|
This is the changelog for the air quality web interface and its associated HTTP API.
|
||||||
|
|
||||||
- `[API]` refers to changes to the [HTTP API](https://aq.connectedhumber.org/__nightdocs/05-API-Docs.html).
|
- `[API]` refers to changes to the [HTTP API](https://aq.connectedhumber.org/__nightdocs/05-API-Docs.html).
|
||||||
- `[Code]` refers to internal changes to the code that have no direct impact on the web interface or the HTTP API, but are significant enough to warrant note.
|
- `[Code]` refers to internal changes to the code that have no direct impact on the web interface or the HTTP API, but are significant enough to warrant note.
|
||||||
- `[Docs]` refers to changes to the [documentation](https://aq.connectedhumber.org/__nightdocs/00-Welcome.html).
|
- `[Docs]` refers to changes to the [documentation](https://aq.connectedhumber.org/__nightdocs/00-Welcome.html).
|
||||||
|
|
||||||
|
## v0.13
|
||||||
|
- Round dates before making API requests to improve caching potential
|
||||||
|
|
||||||
## v0.12
|
## v0.12
|
||||||
- Added loading animation while the map is loading
|
- Added loading animation while the map is loading
|
||||||
- Added device sensor information to the device info tab in the popup
|
- Added device sensor information to the device info tab in the popup
|
||||||
|
|
|
@ -10,6 +10,10 @@ export default {
|
||||||
// The default zoom level to use when loading the page.
|
// The default zoom level to use when loading the page.
|
||||||
default_zoom: 12,
|
default_zoom: 12,
|
||||||
|
|
||||||
|
// The number of minutes to round dates to when making time-based HTTP API requests.
|
||||||
|
// Very useful for improving cache hit rates.
|
||||||
|
date_rounding_interval: 6,
|
||||||
|
|
||||||
heatmap: {
|
heatmap: {
|
||||||
// The radius fo blobs on the heatmap
|
// The radius fo blobs on the heatmap
|
||||||
blob_radius: 0.02
|
blob_radius: 0.02
|
||||||
|
|
|
@ -46,7 +46,23 @@ function human_time(seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rounds a Date to match the specified number of minutes.
|
||||||
|
* Useful when making API requests to improve caching.
|
||||||
|
* @param {Date} date The date to round.
|
||||||
|
* @param {int} interval_minutes The number of minutes to round it to. Should be less than 60.
|
||||||
|
* @return {void} Doesn't return anything - it mutates the original Date object instead.
|
||||||
|
*/
|
||||||
|
function round_date_interval(date, interval_minutes) {
|
||||||
|
date.setSeconds(0);
|
||||||
|
date.setMilliseconds(0);
|
||||||
|
date.setMinutes(
|
||||||
|
Math.floor(date.getMinutes() / interval_minutes) * interval_minutes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
human_duration_unit,
|
human_duration_unit,
|
||||||
human_time_since, human_time
|
human_time_since, human_time,
|
||||||
|
round_date_interval
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ import Specs from './OverlaySpecs.mjs';
|
||||||
|
|
||||||
import Vector2 from '../Helpers/Vector2.mjs';
|
import Vector2 from '../Helpers/Vector2.mjs';
|
||||||
import GetFromUrl from '../Helpers/GetFromUrl.mjs';
|
import GetFromUrl from '../Helpers/GetFromUrl.mjs';
|
||||||
|
import { round_date_interval } from '../Helpers/DateHelper.mjs';
|
||||||
|
|
||||||
class VoronoiManager {
|
class VoronoiManager {
|
||||||
|
|
||||||
|
@ -52,6 +53,8 @@ class VoronoiManager {
|
||||||
this.last_datetime = datetime;
|
this.last_datetime = datetime;
|
||||||
this.last_reading_type = reading_type;
|
this.last_reading_type = reading_type;
|
||||||
|
|
||||||
|
round_date_interval(this.last_datetime, Config.date_rounding_interval);
|
||||||
|
|
||||||
this.spec = Specs[reading_type] || Specs["unknown"];
|
this.spec = Specs[reading_type] || Specs["unknown"];
|
||||||
if(typeof this.spec.chroma == "undefined")
|
if(typeof this.spec.chroma == "undefined")
|
||||||
this.spec.chroma = chroma.scale(Object.values(this.spec.gradient))
|
this.spec.chroma = chroma.scale(Object.values(this.spec.gradient))
|
||||||
|
|
Loading…
Reference in a new issue