feat: server-side alerts filtering with operators and type param#110
Merged
mukama merged 3 commits intoJun 26, 2026
Merged
Conversation
- 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).
bf76bc2 to
7fe3211
Compare
eskawl
approved these changes
Jun 26, 2026
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
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.
tekwani
approved these changes
Jun 26, 2026
mukama
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 returnsERR_INVALID_FILTER.New
typeparam (all|operational|miner) on both endpoints, validated by the route schema:all→ everythingminer→ miner alerts only (matches the miner base type and subtypes likeminer-am-s19xp)operational→ everything except minersIt's ANDed with any explicit
filter/search/sort/pagination, so existing behaviour is unchanged.Thing-level filtering is pushed into the
listThings/getHistoricalLogsqueries; the handler re-applies the filter on the merged result for per-alert fields and multi-rack correctness. Site search also now matches the alertname.Consistency: both endpoints now expose the device type as
type(history previously returneddeviceType) and carrycontainer+position, so the Position column is populated.Notes:
type(wasdeviceType).