Skip to content

Add sorting to device table and gw table #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Feb 10, 2025
Merged

Conversation

ttulka
Copy link
Contributor

@ttulka ttulka commented Dec 13, 2024

No description provided.

@brocaar
Copy link
Contributor

brocaar commented Jan 10, 2025

Hi @ttulka, thanks, I agree this is a useful feature.

One thing however which will cause ambiguity is the order_by field in Protobuf, which is of type string. For example, in this PR one of the fields that can be sorted on is gatewayId. When people are using the gRPC API, users would have no clue what to use (e.g. gatewayId vs gateway_id vs GatewayId vs GatewayID vs GATEWAY_ID). How gRPC / Protobuf exposes the fieldnames is language specific (gateway_id for Rust, GatewayId for Go, gatewayId for JS).

Therefore I think this should be turned into an enum. That would make it very explicit and would self-document what the available options are. As well it avoids run-time errors because of typos, because an incorrect enum value can be catched at compile time.

That would probably also mean that an order_by_desc field needs to be added (type bool) to invert the ordering.

Would you mind updating your PR with these changes?

@ttulka
Copy link
Contributor Author

ttulka commented Jan 21, 2025

Hi @brocaar thanks for your comments!
The proposed changes were implemented by @schmifran - could you take a second look to see if it is okay now?

@brocaar
Copy link
Contributor

brocaar commented Jan 24, 2025

The tests are failing because the code is not formatted using rustfmt. Could you check this?

@schmifran
Copy link
Contributor

@brocaar Thanks a lot for your feedback :)
I implemented all of the requested changes and also improved the formatting 👍 .

@brocaar
Copy link
Contributor

brocaar commented Feb 7, 2025

Hi @ttulka and @schmifran , this morning re-reviewed your changed + I have made some updates to simplify some things (in my opinion) and align it with the existing code (e.g. implementing the FromProto trait for the Proto conversion). This looks good to be merged. Thank you for all your work on this 👏

One question, should we only add sorting for gateways and devices, or would you like to extend this PR to also include sorting for the other tables, now that we have the structure in place for this?

@ttulka
Copy link
Contributor Author

ttulka commented Feb 7, 2025

Hi @brocaar Many thanks!
I find sorting important only in those two tables because the number of gws and sensors can grow rapidly (in our platform, we have hundreds of sensors, and similarly for gws) while other stuff like applications and device types usually stays in small numbers (all up to 10 in our case).

Thus, I don't see much additional value in sorting other entities for now.

Thanks again

@brocaar brocaar merged commit 01246dd into chirpstack:master Feb 10, 2025
3 checks passed
@brocaar
Copy link
Contributor

brocaar commented Feb 10, 2025

Thanks @ttulka and @schmifran, I have merged your work 👍

jtiala pushed a commit to Creowave/chirpstack that referenced this pull request Apr 10, 2025
Co-authored-by: Franka Schmid <fra.schmid@rational-online.com>
Co-authored-by: Orne Brocaar <info@brocaar.com>
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.

3 participants