openwisp-controller icon indicating copy to clipboard operation
openwisp-controller copied to clipboard

Added location and floorplan filters to device list API

Open Srinath0916 opened this issue 4 weeks ago • 6 comments

Checklist

  • [x ] I have read the OpenWISP Contributing Guidelines.
  • [ x] I have manually tested the changes proposed in this pull request.
  • [ x] I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • [ ] I have updated the documentation.

Reference to Existing Issue

Closes #1158.

Description of Changes Added two new query parameters to the Device list API endpoint:

?location= - filters devices by their associated location ?floorplan= - filters devices by their associated floorplan The filters work through the DeviceLocation relationship. Added test cases for both filters.

Screenshot

Screenshot 2025-12-02 at 12 32 31 PM Screenshot 2025-12-02 at 12 36 53 PM Screenshot 2025-12-02 at 1 46 01 PM Screenshot 2025-12-02 at 1 46 21 PM

Srinath0916 avatar Dec 02 '25 15:12 Srinath0916

Hey @Srinath0916 thank you for the PR. Looking at this PR there are some issues that need to be resolved. For starters kindly make sure you read Openwisp Contributing Guidelines as QA checks are failing in the CI build.

Also it looks like the tests are failing because of missing indoor coordinates. Since you are assigning a floorplan in test_filter_devices_by_floorplan, the DeviceLocation model requires the indoor field to be set.

Kindly make sure to run manual tests too before pushing, it would let you know for any inconsistencies.

stktyagi avatar Dec 04 '25 13:12 stktyagi

Hi, thank you for the review, I've added the required indoor field to both device location creations in the test_filter_devices_by_floorplan test. Could you please check if this resolves the issue? Let me know if there's anything else that needs to be fixed.

Thank you.

Srinath0916 avatar Dec 06 '25 19:12 Srinath0916

Hi, @stktyagi , thank you for the review,

I've added the required indoor field to both device location creations in the test_filter_devices_by_floorplan test.

I can see that 12 out of 13 CI checks have passed successfully. The only failing check is Python 3.9 with Django 4.2.0, which appears to be failing due to a dependency issue. This seems to be unrelated to my changes since all other Python versions (3.10, 3.11, 3.12, 3.13) are passing. Could you please let me know if this is a known issue or if there's anything I should do on my end? Looking forward for your feedback on this so i can work on it. Thank you.

Srinath0916 avatar Dec 07 '25 18:12 Srinath0916

Hi @stktyagi , PR #1174 has been merged which drops Python 3.9 support. Could you re-run the checks on this PR? All tests should pass now. Thanks!

Srinath0916 avatar Dec 10 '25 08:12 Srinath0916

Coverage Status

coverage: 98.608% (+0.001%) from 98.607% when pulling 33185a8a7e9b1d73daf1458f1219ab934ba25419 on Srinath0916:issues/device-location-floorplan-filter into aa2561fc452cd91a96b416bfeb565bc7a029fb38 on openwisp:master.

coveralls avatar Dec 10 '25 11:12 coveralls

Hi @pandafy , @stktyagi , all checks are passing now, This PR is ready for review.

Srinath0916 avatar Dec 10 '25 11:12 Srinath0916