Skip to content

feat: server-side alerts filtering with operators and type param#110

Merged
mukama merged 3 commits into
tetherto:developfrom
paragmore:feat/alerts-type-and-operator-filtering
Jun 26, 2026
Merged

feat: server-side alerts filtering with operators and type param#110
mukama merged 3 commits into
tetherto:developfrom
paragmore:feat/alerts-type-and-operator-filtering

Conversation

@paragmore

@paragmore paragmore commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Improves filtering on the alerts endpoints (/auth/alerts/site, /auth/alerts/history) so callers can filter server-side instead of post-processing the response.

Operator-based filter — values can be a scalar (equality), an array ($in), or an operator object. Allowed operators: $eq, $ne, $in, $nin, $gt, $gte, $lt, $lte. Anything outside the field/operator allow-lists returns ERR_INVALID_FILTER.

?filter={"type":{"$ne":"miner"}}
?filter={"severity":["critical","high"]}

New type param (all | operational | miner) on both endpoints, validated by the route schema:

  • omitted / all → everything
  • miner → miner alerts only (matches the miner base type and subtypes like miner-am-s19xp)
  • operational → everything except miners

It's ANDed with any explicit filter/search/sort/pagination, so existing behaviour is unchanged.

Thing-level filtering is pushed into the listThings / getHistoricalLogs queries; the handler re-applies the filter on the merged result for per-alert fields and multi-rack correctness. Site search also now matches the alert name.

Consistency: both endpoints now expose the device type as type (history previously returned deviceType) and carry container + position, so the Position column is populated.

Notes:

- Validate `filter` against allow-listed fields + operators
  ($eq,$ne,$in,$nin,$gt,$gte,$lt,$lte); reject others with ERR_INVALID_FILTER.
- Push thing-level filtering down to the listThings / getHistoricalLogs
  queries instead of filtering only in-memory; re-apply on the merged
  result for per-alert and multi-rack correctness.
- Add `type` query param (all|operational|miner) on the site and history
  endpoints, matching the miner base type and its subtypes (e.g. miner-am-s19xp).
@paragmore paragmore force-pushed the feat/alerts-type-and-operator-filtering branch from bf76bc2 to 7fe3211 Compare June 26, 2026 08:12
tekwani
tekwani previously approved these changes Jun 26, 2026
Add `name` to SITE_ALERTS_SEARCH_FIELDS so search matches the alert name
(history search already covers it).
tekwani
tekwani previously approved these changes Jun 26, 2026
- History now returns the device type as `type` (was `deviceType`), matching
  the site endpoint; history filter field renamed accordingly.
- Site alerts now carry `position` (info.pos) so the Position column is
  populated; both endpoints now expose type/container/position consistently.
@mukama mukama merged commit 22111cc into tetherto:develop Jun 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants