-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* DEAR-115: add datamodel for team * DEAR-115: fix user service tests * DEAR-115: add create team endpoint * DEAR-115: add join team endpoint * DEAR-120 add swagger-api to allowed requests * DEAR-120 add init sqls and testdata * DEAR-120 adjust timestamp, add entities * DEAR-120 add all entities * DEAR-120 add all repos * DEAR-120 add overall happiness score service & controller * DEAR-120 remove comment * DEAR-120 checkstyle * DEAR-120 adjust table names * DEAR-120 rename service, controller, add emotionSurveyRepo * DEAR-120 set userids testdata * DEAR-120 submit happiness survey * DEAR-120 set userids testdata * DEAR-120 get overallhappiness * DEAR-120 add workkinds * DEAR-120 add workkinds, add logger * DEAR-120 add workkind controller * DEAR-120 refactor * DEAR-120 add emotion api, checkstyle * DEAR-120 submit emotion survey * DEAR-120 update emotion_survey_data * DEAR-120 improve get dashbaord data * DEAR-120 add unit tests * DEAR-120 add exceptions, unit tests * DEAR-120 add happinessScore most voted, unit tests * DEAR-120 get happiness average score for workkind * DEAR-120 fix checkstyle * DEAR-120 review * DEAR-120 update query to use dto * DEAR-120 wip review * DEAR-120 resolve conflicts * DEAR-120 resolve conflicts * DEAR-120 clean up workkinds --------- Co-authored-by: Nick Baur <79518844+baurnick@users.noreply.github.com>
- Loading branch information
1 parent
59d1f05
commit 9c6e893
Showing
35 changed files
with
1,088 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,55 @@ | ||
INSERT INTO public.users (id, name, email, "emailVerified", image, username) | ||
VALUES (1, 'Hans Müller', 'hans@test.com', null, null, 'Hansi'); | ||
INSERT INTO users (id, name, email, "emailVerified", image, username) | ||
VALUES (100001, 'Hans Müller', 'hans@test.com', null, null, 'Hansi'), | ||
(100002, 'Berta Roberts', 'berti@test.com', null, null, 'Berti'); | ||
|
||
INSERT INTO public.team (id, name, current_sprint_id, config_id, code, created_by, created_at, active) | ||
VALUES (1, 'Team Alpha', null, null, 'ALF1', 1, '2024-07-13 15:19:11.164000 +00:00', true); | ||
INSERT INTO public.team (id, name, current_sprint_id, config_id, code, created_by, created_at, active) | ||
VALUES (2, 'Team Beta', null, null, 'BET2', 1, '2024-07-13 15:20:22.162000 +00:00', true); | ||
INSERT INTO team (id, name, current_sprint_id, config_id, code, created_by, created_at, active) | ||
VALUES (998, 'Team Alpha', null, null, 'ALF1', 100001, '2024-07-13 15:19:11.164000 +00:00', true), | ||
(999, 'Team Beta', null, null, 'BET2', 100001, '2024-07-13 15:20:22.162000 +00:00', true); | ||
|
||
INSERT INTO public.team_member (id, user_id, team_id, role, active) | ||
VALUES (1, 1, 1, 'ADMIN', true); | ||
INSERT INTO public.team_member (id, user_id, team_id, role, active) | ||
VALUES (2, 1, 2, 'MEMBER', true); | ||
INSERT INTO team_member (id, user_id, team_id, role, active) | ||
VALUES (990, 100001, 998, 'ADMIN', true); | ||
INSERT INTO team_member (id, user_id, team_id, role, active) | ||
VALUES (999, 100002, 999, 'MEMBER', true); | ||
|
||
INSERT INTO public.team_config (id, work_kinds) | ||
INSERT INTO team_config (id, work_kinds) | ||
VALUES (1, '{CODING,MEETING}'); | ||
|
||
INSERT INTO work_kind (name) | ||
VALUES ('Coding'), | ||
('Meeting'), | ||
('Daily Standup'), | ||
('Planning'), | ||
('Review'), | ||
('Retrospective'); | ||
INSERT INTO work_kind (name, team_id) | ||
VALUES ('Team Huddle', 998), | ||
('Bowling', 999); | ||
|
||
INSERT INTO emotion (name) | ||
VALUES ('Angry'), | ||
('Bored'), | ||
('Busy'), | ||
('Disappointed'), | ||
('Energetic'), | ||
('Exhausted'), | ||
('Frustrated'), | ||
('Lonely'), | ||
('Motivated'), | ||
('Nervous'), | ||
('Overwhelmed'), | ||
('Pessimistic'), | ||
('Relaxed'), | ||
('Sick'), | ||
('Stressed'); | ||
|
||
INSERT INTO happiness_survey (user_id, score) | ||
VALUES (100001, 4), | ||
(100001, 2), | ||
(100001, 3), | ||
(100002, 1); | ||
INSERT INTO work_kind_survey (user_id, score, work_kind_id) | ||
VALUES (100001, 6, 1), | ||
(100002, 7, 2); | ||
INSERT INTO emotion_survey (user_id, emotion_id) | ||
VALUES (100001, 1), | ||
(100002, 2); |
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
53 changes: 53 additions & 0 deletions
53
src/main/java/ch/fhnw/deardevbackend/controller/DashboardController.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,53 @@ | ||
package ch.fhnw.deardevbackend.controller; | ||
|
||
import ch.fhnw.deardevbackend.dto.DashboardDTO; | ||
import ch.fhnw.deardevbackend.dto.SubmitEmotionSurveyDTO; | ||
import ch.fhnw.deardevbackend.dto.SubmitHappinessSurveyDTO; | ||
import ch.fhnw.deardevbackend.dto.SubmitWorkKindSurveyDTO; | ||
import ch.fhnw.deardevbackend.entities.EmotionSurvey; | ||
import ch.fhnw.deardevbackend.entities.HappinessSurvey; | ||
import ch.fhnw.deardevbackend.entities.WorkKindSurvey; | ||
import ch.fhnw.deardevbackend.services.DashboardService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@RestController | ||
@RequestMapping("/v1/dashboard") | ||
public class DashboardController { | ||
@Autowired | ||
private DashboardService dashboardService; | ||
|
||
// todo ensure only logged in user can post his entries | ||
|
||
@GetMapping("/{userId}") | ||
public ResponseEntity<DashboardDTO> getDashboardDataByUserId(@PathVariable Integer userId) { | ||
DashboardDTO dashboardDTO = dashboardService.getDashboardDataByUserId(userId); | ||
return ResponseEntity.ok().body(dashboardDTO); | ||
} | ||
|
||
@GetMapping("/happiness/average/{userId}") | ||
public ResponseEntity<Integer> getAverageScoreByUserId(@PathVariable Integer userId) { | ||
Integer averageScore = dashboardService.getAverageScoreByUserId(userId); | ||
return ResponseEntity.ok().body(averageScore); | ||
} | ||
|
||
@PostMapping("/survey/happiness") | ||
public ResponseEntity<HappinessSurvey> submitHappinessSurvey(@RequestBody SubmitHappinessSurveyDTO request) { | ||
HappinessSurvey data = dashboardService.saveHappinessSurvey(request); | ||
return ResponseEntity.ok().body(data); | ||
} | ||
|
||
@PostMapping("survey/workkind") | ||
public ResponseEntity<WorkKindSurvey> submitWorkKindSurvey(@RequestBody SubmitWorkKindSurveyDTO request) { | ||
WorkKindSurvey data = dashboardService.saveWorkKindSurvey(request); | ||
return ResponseEntity.ok().body(data); | ||
} | ||
|
||
@PostMapping("survey/emotion") | ||
public ResponseEntity<EmotionSurvey> submitEmotionSurvey(@RequestBody SubmitEmotionSurveyDTO request) { | ||
EmotionSurvey data = dashboardService.saveEmotionSurvey(request); | ||
return ResponseEntity.ok().body(data); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/ch/fhnw/deardevbackend/controller/EmotionController.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,25 @@ | ||
package ch.fhnw.deardevbackend.controller; | ||
|
||
import ch.fhnw.deardevbackend.entities.Emotion; | ||
import ch.fhnw.deardevbackend.services.EmotionService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/v1/emotions") | ||
public class EmotionController { | ||
|
||
@Autowired | ||
private EmotionService emotionService; | ||
|
||
@GetMapping() | ||
public ResponseEntity<List<Emotion>> getAllEmotions() { | ||
List<Emotion> emotions = emotionService.getEmotions(); | ||
return ResponseEntity.ok(emotions); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/ch/fhnw/deardevbackend/controller/WorkKindController.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,32 @@ | ||
package ch.fhnw.deardevbackend.controller; | ||
|
||
import ch.fhnw.deardevbackend.entities.WorkKind; | ||
import ch.fhnw.deardevbackend.services.WorkKindService; | ||
import ch.fhnw.deardevbackend.services.TeamService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/v1/workkinds") | ||
public class WorkKindController { | ||
|
||
@Autowired | ||
private WorkKindService workKindService; | ||
|
||
@Autowired | ||
private TeamService teamService; | ||
|
||
|
||
@GetMapping("/user/{userId}") | ||
public ResponseEntity<List<WorkKind>> getAllWorkKindsByUserAndTeam(@PathVariable Integer userId) { | ||
List<Integer> teamIds = teamService.getTeamIdsForUser(userId); | ||
List<WorkKind> workKinds = workKindService.getWorkKindsForTeams(teamIds); | ||
return ResponseEntity.ok(workKinds); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ch/fhnw/deardevbackend/dto/DashboardDTO.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,16 @@ | ||
package ch.fhnw.deardevbackend.dto; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class DashboardDTO { | ||
private MostVotedWorkKindDTO mostVotedWorkKind; | ||
private Integer averageScore; | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/ch/fhnw/deardevbackend/dto/MostVotedWorkKindDTO.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,15 @@ | ||
package ch.fhnw.deardevbackend.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class MostVotedWorkKindDTO { | ||
private Integer workKindId; | ||
private String workKindName; | ||
private Integer voteCount; | ||
private Integer happinessScore; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/ch/fhnw/deardevbackend/dto/SubmitEmotionSurveyDTO.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,9 @@ | ||
package ch.fhnw.deardevbackend.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class SubmitEmotionSurveyDTO { | ||
private Integer userId; | ||
private Integer emotionId; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/ch/fhnw/deardevbackend/dto/SubmitHappinessSurveyDTO.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,9 @@ | ||
package ch.fhnw.deardevbackend.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class SubmitHappinessSurveyDTO { | ||
private Integer userId; | ||
private Integer score; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/ch/fhnw/deardevbackend/dto/SubmitWorkKindSurveyDTO.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,10 @@ | ||
package ch.fhnw.deardevbackend.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class SubmitWorkKindSurveyDTO { | ||
private Integer userId; | ||
private Integer score; | ||
private Integer workKindId; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/ch/fhnw/deardevbackend/entities/Emotion.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,22 @@ | ||
package ch.fhnw.deardevbackend.entities; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "emotion") | ||
@Builder | ||
@Data | ||
public class Emotion { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
|
||
@Column(name = "name") | ||
private String name; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/ch/fhnw/deardevbackend/entities/EmotionSurvey.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,33 @@ | ||
package ch.fhnw.deardevbackend.entities; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "emotion_survey") | ||
@Builder | ||
@Data | ||
public class EmotionSurvey { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
|
||
@Column(name = "user_id") | ||
private Integer userId; | ||
|
||
@Column(name = "submitted", columnDefinition = "TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) | ||
private String submitted; | ||
|
||
@Column(name = "emotion_id") | ||
private Integer emotionId; | ||
|
||
|
||
|
||
|
||
|
||
} |
Oops, something went wrong.