-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend/frontend] Improv performance on teams (#1409)
- Loading branch information
1 parent
5d42857
commit ee7c842
Showing
35 changed files
with
785 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
openbas-api/src/main/java/io/openbas/rest/team/ExerciseTeamApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.openbas.rest.team; | ||
|
||
import io.openbas.database.model.Team; | ||
import io.openbas.rest.helper.RestBehavior; | ||
import io.openbas.rest.team.output.TeamOutput; | ||
import io.openbas.service.TeamService; | ||
import io.openbas.telemetry.Tracing; | ||
import io.openbas.utils.pagination.SearchPaginationInput; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.jpa.domain.Specification; | ||
import org.springframework.security.access.annotation.Secured; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import static io.openbas.database.model.User.ROLE_USER; | ||
import static io.openbas.database.specification.TeamSpecification.contextual; | ||
import static io.openbas.database.specification.TeamSpecification.fromExercise; | ||
import static io.openbas.rest.exercise.ExerciseApi.EXERCISE_URI; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@Secured(ROLE_USER) | ||
public class ExerciseTeamApi extends RestBehavior { | ||
|
||
private final TeamService teamService; | ||
|
||
@PostMapping(EXERCISE_URI + "/{exerciseId}/teams/search") | ||
@PreAuthorize("isExerciseObserver(#exerciseId)") | ||
@Transactional(readOnly = true) | ||
@Tracing(name = "Paginate teams for exercise", layer = "api", operation = "POST") | ||
public Page<TeamOutput> searchTeams( | ||
@PathVariable @NotBlank final String exerciseId, | ||
@RequestBody @Valid SearchPaginationInput searchPaginationInput) { | ||
final Specification<Team> teamSpecification = contextual(false).or(fromExercise(exerciseId).and(contextual(true))); | ||
return this.teamService.teamPagination(searchPaginationInput, teamSpecification); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
openbas-api/src/main/java/io/openbas/rest/team/ScenarioTeamApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.openbas.rest.team; | ||
|
||
import io.openbas.database.model.Team; | ||
import io.openbas.rest.helper.RestBehavior; | ||
import io.openbas.rest.team.output.TeamOutput; | ||
import io.openbas.service.TeamService; | ||
import io.openbas.telemetry.Tracing; | ||
import io.openbas.utils.pagination.SearchPaginationInput; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.jpa.domain.Specification; | ||
import org.springframework.security.access.annotation.Secured; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import static io.openbas.database.model.User.ROLE_USER; | ||
import static io.openbas.database.specification.TeamSpecification.contextual; | ||
import static io.openbas.database.specification.TeamSpecification.fromScenario; | ||
import static io.openbas.rest.scenario.ScenarioApi.SCENARIO_URI; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@Secured(ROLE_USER) | ||
public class ScenarioTeamApi extends RestBehavior { | ||
|
||
private final TeamService teamService; | ||
|
||
@PostMapping(SCENARIO_URI + "/{scenarioId}/teams/search") | ||
@PreAuthorize("isScenarioObserver(#scenarioId)") | ||
@Transactional(readOnly = true) | ||
@Tracing(name = "Paginate teams for scenario", layer = "api", operation = "POST") | ||
public Page<TeamOutput> teams( | ||
@PathVariable @NotBlank final String scenarioId, | ||
@RequestBody @Valid SearchPaginationInput searchPaginationInput) { | ||
final Specification<Team> teamSpecification = contextual(false).or(fromScenario(scenarioId).and(contextual(true))); | ||
return this.teamService.teamPagination(searchPaginationInput, teamSpecification); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.