Skip to content
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

[GridDyna] Add some batch CRUD endpoints #111

Merged
merged 24 commits into from
Jul 12, 2024

Conversation

thangqp
Copy link
Contributor

@thangqp thangqp commented May 7, 2024

@Mathieu-Deharbe Mathieu-Deharbe self-requested a review June 21, 2024 14:04
Copy link

@Mathieu-Deharbe Mathieu-Deharbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not finished, not tested yet.

@PostMapping(value = "/filters", params = "duplicateFrom")
@Operation(summary = "Duplicate a filter")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The filter has been successfully created"),
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The uuid of the new filter has been successfully duplicated"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The uuid of the new filter has been successfully duplicated"),
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The filter with uuid filterId has been successfully duplicated"),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I have a slight change from your suggestion to "The filter with given id has been successfully duplicated"

@@ -85,8 +95,19 @@ public ResponseEntity<UUID> duplicateFilter(@RequestParam("duplicateFrom") UUID
.orElse(ResponseEntity.notFound().build());
}

@PostMapping(value = "/filters/batch/duplicate")
@Operation(summary = "Duplicate filters from provided uuids")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The map of sourceUuid and newUuid of duplicated filters"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The map of sourceUuid and newUuid of duplicated filters"),
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Filters have been successfully duplicated."),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I have a slight change from your suggestion to "Filters of given ids have been successfully duplicated"

@@ -205,13 +219,70 @@ public <F extends AbstractFilter> void changeFilter(UUID id, F newFilter, String
notificationService.emitElementUpdated(id, userId);
}

@Transactional
public List<AbstractFilter> changeFilters(Map<UUID, AbstractFilter> filtersToModifyMap) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public List<AbstractFilter> changeFilters(Map<UUID, AbstractFilter> filtersToModifyMap) {
public List<AbstractFilter> updateFilters(Map<UUID, AbstractFilter> filtersToModifyMap) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is quite complicated. As we can assume only few filters will be updated at one time, you can iterate on filtersToModifyMap and call changeFilter.
And rename changeFilter to updateFilter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0e8609f

@@ -85,18 +95,38 @@ public ResponseEntity<UUID> duplicateFilter(@RequestParam("duplicateFrom") UUID
.orElse(ResponseEntity.notFound().build());
}

@PostMapping(value = "/filters/batch/duplicate")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding duplicate looks like a good way to differentiate the two /filters/batch but I don't get the fact that this has not be done for the 2 @PostMapping(value = "/filters") (the creation and the duplication have the same path).

Our rest API best practices are not very precise about extra data like this. But they state that the path should only be used to identify a data.

@etiennehomer shouldn't we modify the filters duplication signature in an other PR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add "duplicate" in the path of duplicate endpoint, i.e. POST /filters/duplicate but we have to changer also in gridexplorer-app. I think we can change in another TS

In fact we should have :
POST /filters
POST /filters/batch
POST /filters/duplicate
POST /filters/duplicate/batch

At least I can change from /filters/batch/duplicate to /filters/duplicate/batch, what do you think??? @etiennehomer @Mathieu-Deharbe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I think the API you propose is good Thang. So let's change POST /filters/batch/duplicate to POST /filters/duplicate/batch
And then, in another PR, let's change for unitary duplication endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE in 0713dfc

Copy link

@jonenst
Copy link
Contributor

jonenst commented Jul 11, 2024

Read through it nothing stands out as blocking

@jonenst
Copy link
Contributor

jonenst commented Jul 11, 2024

nitpick: /batch endpoints do we have endpoints like this in other parts of the code ?

@thangqp
Copy link
Contributor Author

thangqp commented Jul 12, 2024

nitpick: /batch endpoints do we have endpoints like this in other parts of the code ?

NO, I use /batch to distinguish two endpoints 'single' and 'batch' processing for the same HTTP verb POST

@thangqp thangqp merged commit 1cb6ca5 into main Jul 12, 2024
3 checks passed
@thangqp thangqp deleted the dynamic_simulation_add_some_batch_crud_endpoint_ branch July 12, 2024 16:15
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