Skip to content

Get multiple statuses at once - #235

Open
sBouzols wants to merge 6 commits into
mainfrom
get_computation_status_for_multiple_results_at_once
Open

Get multiple statuses at once#235
sBouzols wants to merge 6 commits into
mainfrom
get_computation_status_for_multiple_results_at_once

Conversation

@sBouzols

@sBouzols sBouzols commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Add POST "/results/statuses" endpoint to get multiple statuses at once given a collection of resultUuids in body

Do I remove the previous endpoint ?
-> No

…s at once given a collection of resultUuids in body

Signed-off-by: sBouzols <sylvain.bouzols@gmail.com>
@sBouzols
sBouzols requested a review from SlimaneAmar April 30, 2026 14:56
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Repository interfaces GlobalStatusRepository and ResultRepository remove custom findByResultUuid/deleteByResultUuid methods, relying on JpaRepository's findById/deleteById. LoadFlowResultService is updated accordingly. LoadFlowController adds a POST /results/statuses endpoint. pom.xml pins gridsuite-computation.version. Tests are updated and added.

Changes

Status/result repository refactor and new endpoint

Layer / File(s) Summary
Remove custom repository query methods
src/main/java/org/gridsuite/loadflow/server/repositories/GlobalStatusRepository.java, src/main/java/org/gridsuite/loadflow/server/repositories/ResultRepository.java
Custom findByResultUuid and deleteByResultUuid method declarations are removed, leaving only inherited JpaRepository methods.
Update service to use primary-key repository methods
src/main/java/org/gridsuite/loadflow/server/service/LoadFlowResultService.java
delete, findResults, findStatus, and findStatuses are switched to findById, deleteById, and findAllById instead of the removed custom methods.
Add /results/statuses endpoint and tests
src/main/java/org/gridsuite/loadflow/server/LoadFlowController.java, src/test/java/org/gridsuite/loadflow/server/LoadFlowControllerTest.java
A new POST /results/statuses endpoint returns a map of UUID to LoadFlowStatus; a new test covers it, and an existing test's assertion is updated to use findById.
Pin gridsuite-computation dependency version
pom.xml
Adds a gridsuite-computation.version property set to 2.3.0-SNAPSHOT with a FIXME comment, and adds an explicit <version> element to the corresponding dependency.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant LoadFlowController
  participant LoadFlowResultService
  participant GlobalStatusRepository
  Client->>LoadFlowController: POST /results/statuses (resultUuids)
  LoadFlowController->>LoadFlowResultService: getStatuses(resultUuids)
  LoadFlowResultService->>GlobalStatusRepository: findAllById(resultUuids)
  GlobalStatusRepository-->>LoadFlowResultService: List<GlobalStatusEntity>
  LoadFlowResultService-->>LoadFlowController: Map<UUID, LoadFlowStatus>
  LoadFlowController-->>Client: 200 OK with status map
Loading

Suggested reviewers: TheMaskedTurtle, antoinebhs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: retrieving multiple statuses in one request.
Description check ✅ Passed The description is directly related to the new bulk /results/statuses endpoint and notes the previous endpoint remains.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch get_computation_status_for_multiple_results_at_once

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread pom.xml
<sonar.organization>gridsuite</sonar.organization>
<sonar.projectKey>org.gridsuite:loadflow-server</sonar.projectKey>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<gridsuite-computation.version>2.3.0-SNAPSHOT</gridsuite-computation.version>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't forget to delete it

sBouzols and others added 2 commits May 13, 2026 11:24
Signed-off-by: sBouzols <sylvain.bouzols@gmail.com>
Co-authored-by: Copilot <copilot@github.com>
Signed-off-by: sBouzols <sylvain.bouzols@gmail.com>
@sBouzols sBouzols changed the title [WIP] Get multiple statuses at once Get multiple statuses at once May 21, 2026
sBouzols added 3 commits May 21, 2026 16:49
…s_for_multiple_results_at_once

Signed-off-by: sBouzols <sylvain.bouzols@gmail.com>
…balStatusEntity` then no need for specific methods in Jpa Repositories (#239)

Signed-off-by: sBouzols <sylvain.bouzols@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/gridsuite/loadflow/server/service/LoadFlowResultService.java`:
- Around line 236-240: `LoadFlowResultService.findStatuses` currently uses
`Collectors.toMap` on `GlobalStatusEntity::getStatus`, which can fail when a row
has a null status. Update this method to match `findStatus()` behavior by making
the collection null-tolerant, either by filtering out null statuses before
collecting or by mapping them safely so `null` values do not break the result
map.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c37aee0e-653d-476a-bfb4-029eebcc2239

📥 Commits

Reviewing files that changed from the base of the PR and between 6358837 and 1d43e01.

📒 Files selected for processing (6)
  • pom.xml
  • src/main/java/org/gridsuite/loadflow/server/LoadFlowController.java
  • src/main/java/org/gridsuite/loadflow/server/repositories/GlobalStatusRepository.java
  • src/main/java/org/gridsuite/loadflow/server/repositories/ResultRepository.java
  • src/main/java/org/gridsuite/loadflow/server/service/LoadFlowResultService.java
  • src/test/java/org/gridsuite/loadflow/server/LoadFlowControllerTest.java
💤 Files with no reviewable changes (2)
  • src/main/java/org/gridsuite/loadflow/server/repositories/GlobalStatusRepository.java
  • src/main/java/org/gridsuite/loadflow/server/repositories/ResultRepository.java

Comment on lines +236 to 240
public Map<UUID, LoadFlowStatus> findStatuses(List<UUID> resultUuids) {
Objects.requireNonNull(resultUuids);
List<GlobalStatusEntity> globalEntities = globalStatusRepository.findAllById(resultUuids);
return globalEntities.stream().collect(Collectors.toMap(GlobalStatusEntity::getResultUuid, GlobalStatusEntity::getStatus));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check GlobalStatusEntity field annotations for nullability constraints
rg -n -A2 'status' --type=java src/main/java/org/gridsuite/loadflow/server/entities/GlobalStatusEntity.java

Repository: gridsuite/loadflow-server

Length of output: 210


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== LoadFlowResultService excerpt =="
sed -n '220,245p' src/main/java/org/gridsuite/loadflow/server/service/LoadFlowResultService.java | cat -n

echo
echo "== GlobalStatusEntity file =="
sed -n '1,120p' src/main/java/org/gridsuite/loadflow/server/entities/GlobalStatusEntity.java | cat -n

echo
echo "== Search for status nullability / schema constraints =="
rg -n --hidden --glob '!target/**' --glob '!build/**' --glob '!dist/**' \
  '`@Column`\\(|nullable\\s*=\\s*false|status.*not null|not null.*status|GlobalStatusEntity' \
  src main resources .

Repository: gridsuite/loadflow-server

Length of output: 2975


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for globalStatus schema/migrations =="
rg -n --hidden --glob '!target/**' --glob '!build/**' --glob '!dist/**' \
  'globalStatus|global_status|status' \
  src/main/resources src/main/java

echo
echo "== Search for migration files =="
fd -a -t f '.*(sql|xml|yml|yaml)$' src/main/resources db . | sed -n '1,200p'

Repository: gridsuite/loadflow-server

Length of output: 11245


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,40p' src/main/resources/db/changelog/changesets/changelog_20230606T161304Z.xml | cat -n

Repository: gridsuite/loadflow-server

Length of output: 3073


Handle nullable status in findStatuses

global_status.status is nullable in both the entity and the Liquibase DDL, so Collectors.toMap(...) can throw if any row has a null status. findStatus() already returns null in that case; make findStatuses() use a null-tolerant collector or filter nulls first.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/loadflow/server/service/LoadFlowResultService.java`
around lines 236 - 240, `LoadFlowResultService.findStatuses` currently uses
`Collectors.toMap` on `GlobalStatusEntity::getStatus`, which can fail when a row
has a null status. Update this method to match `findStatus()` behavior by making
the collection null-tolerant, either by filtering out null statuses before
collecting or by mapping them safely so `null` values do not break the result
map.

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.

2 participants