Commit Graph

99 Commits

Author SHA1 Message Date
Paul van Tilburg 3451445de1
Update the changelog 2022-05-21 09:51:59 +02:00
Paul van Tilburg b88c7f77a0
Bump the version to 0.2.3 2022-05-21 09:49:18 +02:00
Paul van Tilburg 705ffae249
Fix typo in map key color for level 8 2022-05-21 09:47:23 +02:00
Paul van Tilburg bd2344beb6
Transform map key colors to hexadecimal format 2022-05-21 09:47:01 +02:00
Paul van Tilburg bad20b803a
Don't set unnecessary status 2022-05-10 15:47:37 +02:00
Paul van Tilburg fc4672328f
Fix missing type for tests
This was introduced by the changes in commit e204e79.
2022-05-10 15:47:08 +02:00
Paul van Tilburg 769f0745c8
Update examples with fixes of v0.2.2 taken into account 2022-05-10 15:26:58 +02:00
Paul van Tilburg 3fb899d1fd
Update the changelog 2022-05-10 15:05:57 +02:00
Paul van Tilburg f0cc54f074
Bump the version to 0.2.2 2022-05-10 14:58:21 +02:00
Paul van Tilburg ac653ef0c9
Cargo update 2022-05-10 14:57:03 +02:00
Paul van Tilburg e204e7905c
Update to Rocket 0.5-rc.2 2022-05-10 14:55:57 +02:00
Paul van Tilburg 08cdfe1e1c Merge pull request 'Fix timestamps for map samples not being correct' (#22) from 21-fix-ts-map-samples into main
Reviewed-on: #22
2022-05-10 14:26:38 +02:00
Paul van Tilburg 89395f21f6
Introduce RetrievedMaps; refactor around it
The `RetrievedMaps` struct captures the image and its metadata:
the last modification time and the base timestamp for the maps.

* No longer store the last modification time, called "stamp" before,
  separately in the `Maps` struct
* Update methods on `Maps` to use the `RetrievedMaps` structs and
  the timestamp base in particular for sampling and map marking
* Update the `MapsRefresh` implemention to use the last modification
  time
* Rename some variables from `map` to `image` in the helper functions
  for consistency
* Update tests and documentation
2022-05-10 14:19:09 +02:00
Paul van Tilburg ff9f1ac371
Parse timestamp base from filename 2022-05-10 13:21:21 +02:00
Paul van Tilburg 4a6eeab787
Fix sample/item being out of the combined series time range
For example, if there are 24 valid pollen samples and 20 valid air
quality items, the maximum pollen sample could be de 23th, but the
resulting combined series will only cover 20 items. So, it is should not
return that, but only look in the first 20 pollen samples for the
maximum sample.
2022-05-10 12:26:10 +02:00
Paul van Tilburg ab4b0bba72
Fix valid samples/items being discarded too early
A forecasted sample/item may be for example timestamped at 14:00.
For hourly forecasts, it will still be valid until 14:59:59, not
14:29:59.
2022-05-10 12:24:26 +02:00
Paul van Tilburg b61eb63cdf
Update the changelog 2022-05-08 14:04:05 +02:00
Paul van Tilburg e5e006dc00
Bump the version to 0.2.1 2022-05-08 14:02:47 +02:00
Paul van Tilburg a0c4e0da77
Don't use Option for the max sample/item return values
If the sample/item series are empty, the function already returns
`None`, so the tuple values are always `Some(_)` which makes the
`Option` type redundant.
2022-05-08 14:01:22 +02:00
Paul van Tilburg 34b63ec94d
Compact merge tests by using constructors
Add the constructors to sample/item structs for testing purposes.
2022-05-08 14:00:12 +02:00
Paul van Tilburg 5a23e83b7f
Extend tests for combined provider merge function
* Check that merging fails if the samples/items are too far apart
* Check that nothing is returned if either of the lists is empty
* Check that if either series is shifted, they are merged correctly
2022-05-08 13:48:09 +02:00
Paul van Tilburg e2d1a1d9df
Filter out old item/samples in combined provider
* Only retain samples/items that have timestamps that are at least half
  an hour ago
* Add a test to verify that the merge discards them
2022-05-08 12:53:32 +02:00
Paul van Tilburg 29b79c720d
Derive PartialEq for most item/sample structs 2022-05-08 12:53:09 +02:00
Paul van Tilburg 5d37c5b5ee
Bump the version to 0.2.0 2022-05-07 21:55:03 +02:00
Paul van Tilburg 2c04a92965
Update the changelog 2022-05-07 21:54:53 +02:00
Paul van Tilburg e408fbb91d
Add a changelog 2022-05-07 21:50:59 +02:00
Paul van Tilburg 5972697cf1
Yield pollen and AQI max for PAQI metric (closes: #20)
* Make the combined provider keep track of the AQI and pollen maximum
  value
* Extend the `Forecast` struct with the `aqi_max` and `pollen_max`
  fields
* Fill the `aqi_max` and `pollen_max` fields when the PAQI metric is
  selected
* Update the documentation
* Extend the tests
2022-05-07 21:43:35 +02:00
Paul van Tilburg 7feae97ee2
Bump dependencies; cargo update 2022-05-07 20:21:09 +02:00
Paul van Tilburg 0bf07bd134
Split off all functionality to a library crate
This way we can build Rockets from outside the crate and run benchmarks,
for example.

* Add top-level `setup()` function to create a Rocket and set up the
  maps refresher task
* Change the type of `maps::run` since `!` is still an unstable type
* Fix HTTP code blocks in `README.md` so they don't appear as doctests
  to rustdoc
2022-03-15 09:54:02 +01:00
Paul van Tilburg 4576f8d90a
More textual improvements 2022-03-11 16:35:38 +01:00
Paul van Tilburg 66bd02ea57
Also document the map API endpoint
Because, why not?
2022-03-11 16:18:04 +01:00
Paul van Tilburg 80fd9525c4
Fix missing endpoint in example URLs; tweak text a bit 2022-03-11 16:09:14 +01:00
Paul van Tilburg 32964cea21
Add basic top-level tests
This starts to address #14 but didn't turn into a full MR yet.

* Use crates `assert_float_eq` and `assert_matches` for extra assertions
* Split off a function to build a Rocket `rocket()` that can be used
  in the tests
2022-03-11 16:03:56 +01:00
Paul van Tilburg 738409c3a8
Fix bound check using constant value
It should use the actual count instead!
2022-03-07 19:19:14 +01:00
Paul van Tilburg 65a4420191
Bump dependency; cargo update
Bump the dependency on `cached` to 0.32.0 (fixes documentation)
2022-02-26 09:36:15 +01:00
Paul van Tilburg dc90f57422 Document API response; fix typo 2022-02-25 15:43:15 +01:00
Paul van Tilburg 512f170804 Bump dependencies; cargo update
* Bump the dependency on `image` to 0.24.1 (PNG bugfix)
* Bump the dependency on `cached` to 0.31.0 (I/O caching support?)
2022-02-25 15:26:44 +01:00
Paul van Tilburg 8b1dee96e0 Merge pull request 'Implement PAQI metric' (#16) from 15-implement-paqi into main
Reviewed-on: #16
2022-02-24 20:43:34 +01:00
Paul van Tilburg d33b5f1dbb
Hook up the combined metric in the forecast 2022-02-24 20:40:35 +01:00
Paul van Tilburg 95f30751c6
Add the combined provider 2022-02-24 20:40:07 +01:00
Paul van Tilburg 1ae6c896dd
Make item/sample fields available to the crate 2022-02-24 20:23:33 +01:00
Paul van Tilburg d0ace275ec
Filter out items that are older than 1h before now
Luchtmeetnet seems to yield some results that are in the past some
times?
2022-02-24 20:21:55 +01:00
Paul van Tilburg a78c55332f Refactor the API for the maps module
* Move the function `draw_position` to the maps module and split it up
* Replace and refactor `pollen_at` and `uvi_at` methods on `Maps`
  by `pollen_mark` and `uvi_mark`
* Drop the `pollen_project` and `uvi_project` methods on `Maps`,
  just call the `project` helper method directly
* Add `map_at` and `mark` helper methods that handle maps slicing
  and drawing
* Rename `pollen_sample` and `uvi_sample` methods on `Maps` to their
  plural forms
* Also, rename the map handlers to `map_address` and `map_geo`
2022-02-22 12:49:42 +01:00
Paul van Tilburg 9cd4be160c Update description; add authors and repository fields 2022-02-21 21:05:50 +01:00
Paul van Tilburg 9e9955fb58 Add Debian packaging via cargo-deb
* Add the required metadata to `Cargo.toml`
* Add a systemd unit file
* Use `Rocket.toml.example` as the default configuration
2022-02-21 20:55:00 +01:00
Paul van Tilburg 4db8e4ac03 Add Rocket.toml example file; fix syntax
Also ignore a local `Rocket.toml`; it can be used for development
without comitting it.
2022-02-21 20:54:32 +01:00
Paul van Tilburg 84a434268f
Add README.md and LICENSE file (closes: #6)
Also link the files from the crate and include `README.md` as main crate
documentation.
2022-02-21 17:48:28 +01:00
Paul van Tilburg 7432fb3cd3 Fix Buienradar timestamp madness (closes: #3)
* Use the `Europe::Amsterdam` time zone from `chrono_tz` to determine
  what date/time it is in that time zone
* Parse timestamps in the rain text API relative to this date/time
* Add the `fix_items_day_boundary` function to fix up stuff if
  the series of timestamps in the rain text cross the day boundary
2022-02-20 17:39:49 +01:00
Paul van Tilburg 17d5daeabc Use chrono (UTC) timestamps for maps (closes: #12)
* Adapt `retrieve_image` to also return a timestamp based on the
  CDN's last modified time; adapt other methods accordingly
* For the maps module, use `chrono::Utc` instead of
  `tokio::time::Instant` and use `chrono::Duration` instead of
  `tokio::time::Duration`
* Pass the maps timestamp to the `sample` function so it can use
  that timestamp as base
2022-02-19 16:45:37 +01:00
Paul van Tilburg a5ca1f02ff Merge pull request 'Implment the pollen and UV index metrics' (#13) from 4-implement-pollen-uvi into main
Reviewed-on: #13
2022-02-19 15:42:57 +01:00