You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimise queries to save Blocked Device Info in Repository (#683)
<!-- Please provide brief information about the PR, what it contains &
its purpose, new behaviors after the change. And let us know here if you
need any help: https://github.com/microsoft/HydraLab/issues/new -->
## Description
This pull request includes several changes to the
`DeviceAgentManagementService` and its related repository to improve the
handling of blocked devices. The most important changes involve
replacing direct repository calls with `Optional` checks, consolidating
delete operations, and simplifying imports.
Improvements to blocked device handling:
*
[`center/src/main/java/com/microsoft/hydralab/center/service/DeviceAgentManagementService.java`](diffhunk://#diff-289317ad410c52c217b55f97dc31f0806ffad3b4cc737a56e255701ad77f3797L1163-R1166):
Replaced direct repository calls with `Optional` checks to handle the
presence of blocked devices more safely.
*
[`center/src/main/java/com/microsoft/hydralab/center/service/DeviceAgentManagementService.java`](diffhunk://#diff-289317ad410c52c217b55f97dc31f0806ffad3b4cc737a56e255701ad77f3797L1197-R1208):
Simplified the `unBlockDevice` method by consolidating delete operations
into a single repository method `deleteIfExists`.
Repository improvements:
*
[`common/src/main/java/com/microsoft/hydralab/common/repository/BlockedDeviceInfoRepository.java`](diffhunk://#diff-f76c5b6f6c8de8f14263d4913754c060bd181a96e20e8aeff3728fd254a9e15aL4-R27):
Added `Optional` return type for `findByBlockedDeviceSerialNumber` and
consolidated delete operations into a new method `deleteIfExists`.
Codebase simplification:
*
[`center/src/test/java/com/microsoft/hydralab/center/service/DeviceAgentManagementServiceTest.java`](diffhunk://#diff-6562c25d5fc53e481385e45d6835f0017d51ca06bcbe2a6bdbee489a0c15e51cL86-L97):
Updated test cases to use the new `deleteIfExists` method.
<!-- A few words to explain your changes -->
### Linked GitHub issue ID: #
#685
## Pull Request Checklist
<!-- Put an x in the boxes that apply. This is simply a reminder of what
we are going to look for before merging your code. -->
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] Code compiles correctly with all tests are passed.
- [x] I've read the [contributing
guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code)
and followed the recommended practices.
- [ ] [Wikis](https://github.com/microsoft/HydraLab/wiki) or
[README](https://github.com/microsoft/HydraLab/blob/main/README.md) have
been reviewed and added / updated if needed (for bug fixes / features)
### Does this introduce a breaking change?
*If this introduces a breaking change for Hydra Lab users, please
describe the impact and migration path.*
- [ ] Yes
- [x] No
## How you tested it
*Please make sure the change is tested, you can test it by adding UTs,
do local test and share the screenshots, etc.*
Yes , tested it multiple times by blocking and unblocking devices and
using unit tests.
**Blocking a device**
<img width="1358" alt="block"
src="https://github.com/user-attachments/assets/edc93fa5-f35a-4fab-86b7-eddf9c18253d"
/>
**Unblocking a device**
<img width="1336" alt="unblock"
src="https://github.com/user-attachments/assets/e0328868-ffc7-42fd-89cd-7367b8f2a988"
/>
Please check the type of change your PR introduces:
- [x] Bugfix
- [ ] Feature
- [ ] Technical design
- [ ] Build related changes
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Code style update (formatting, renaming) or Documentation content
changes
- [ ] Other (please describe):
### Feature UI screenshots or Technical design diagrams
*If this is a relatively large or complex change, kick it off by drawing
the tech design with PlantUML and explaining why you chose the solution
you did and what alternatives you considered, etc...*
---------
Co-authored-by: Ujjwal Srivastava <[email protected]>
Co-authored-by: Ujjwal Srivastava <[email protected]>
0 commit comments