Skip to content

Commit

Permalink
fix: (#2) (#9)
Browse files Browse the repository at this point in the history
* fix: modify jpql

* fix: modify jpql

* fix: remove picked task from tasks in response

* fix: remove picked task from tasks in response
  • Loading branch information
aiaiaiai1 authored Jul 17, 2024
1 parent fe06286 commit 97526fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/main/java/gymmi/repository/WorkspaceRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ default Workspace getWorkspaceById(Long id) {
"limit 10 offset :pageNumber", nativeQuery = true)
List<Workspace> getJoinedWorkspacesByUserIdOrderBy_(Long userId, int pageNumber);

@Query("select count(*) from Workspace w where w.status = 'PREPARING' or w.status = 'IN_PROGRESS'")
@Query("select count(*) from Workspace ws join Worker w on ws.id = w.workspace.id " +
"where (ws.status = 'PREPARING' or ws.status = 'IN_PROGRESS') " +
"and w.user.id = :userId")
int getCountsOfJoinedWorkspacesWhereStatusIsPreparingOrInProgress(Long userId);


Expand Down
8 changes: 5 additions & 3 deletions src/main/java/gymmi/response/OpeningTasksBoxResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import gymmi.entity.Task;
import gymmi.exception.ServerLogicFaultException;
import java.util.List;
import lombok.Getter;

import java.util.List;

@Getter
public class OpeningTasksBoxResponse {

Expand All @@ -13,11 +14,12 @@ public class OpeningTasksBoxResponse {

public OpeningTasksBoxResponse(List<Task> tasks) {
this.pickedTask = getPickedTask(tasks);
this.tasks = getTask(tasks);
this.tasks = getRestTasks(tasks);
}

private List<TaskDTO> getTask(List<Task> tasks) {
private List<TaskDTO> getRestTasks(List<Task> tasks) {
return tasks.stream()
.filter(t -> !t.isPicked())
.map(t -> new TaskDTO(t.getId(), t.getName(), t.getRegister().getNickname()))
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ class 미션_수행 {
response.then().log().all()
.statusCode(200)
.body("pickedTask", Matchers.notNullValue())
.body("tasks", Matchers.hasSize(2));
.body("tasks", Matchers.hasSize(1));
}

@Nested
Expand Down

0 comments on commit 97526fe

Please sign in to comment.