Skip to content

Commit

Permalink
Merge branch 'main' into DEAR-124
Browse files Browse the repository at this point in the history
  • Loading branch information
baurnick committed Aug 4, 2024
2 parents 1d9f307 + ad029e2 commit 7ed99d3
Show file tree
Hide file tree
Showing 21 changed files with 1,036 additions and 367 deletions.
4 changes: 1 addition & 3 deletions database/02_test_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ 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);
456 changes: 233 additions & 223 deletions database/03_test__survey_data.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package ch.fhnw.deardevbackend.controller;

import ch.fhnw.deardevbackend.dto.*;
import ch.fhnw.deardevbackend.dto.insights.InsightDTO;
import ch.fhnw.deardevbackend.services.InsightsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
Expand All @@ -17,7 +16,7 @@ public class InsightsController {
@Autowired
private InsightsService insightsService;

// Overall

@GetMapping("/{userId}/team/{teamId}/sprint/{sprint}")
public ResponseEntity<InsightDTO> getInsightsByTeamAndSprint(@PathVariable Integer userId,
@PathVariable Integer teamId,
Expand All @@ -26,16 +25,4 @@ public ResponseEntity<InsightDTO> getInsightsByTeamAndSprint(@PathVariable Integ
return ResponseEntity.ok(insights);
}

// happiness team vs personal
@GetMapping("/happiness/{userId}/team/{teamId}/sprint/{sprint}")
public ResponseEntity<List<HappinessInsightDTO>> getHappinessInsightsByTeam(
@PathVariable Integer userId, @PathVariable Integer teamId, @PathVariable String sprint) {
try {
List<HappinessInsightDTO> insights = insightsService.getHappinessInsightsByTeam(userId, teamId, sprint);
return ResponseEntity.ok(insights);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}

}
13 changes: 0 additions & 13 deletions src/main/java/ch/fhnw/deardevbackend/dto/InsightDTO.java

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ch.fhnw.deardevbackend.dto.insights;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class EmotionInsightDTO {
private Integer emotionId;
private String emotionName;
private Long userCount;
private Long teamCount;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.fhnw.deardevbackend.dto;
package ch.fhnw.deardevbackend.dto.insights;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -7,6 +7,6 @@
@AllArgsConstructor
public class HappinessInsightDTO {
private String day;
private double userAverage;
private double teamAverage;
private Double userAverage;
private Double teamAverage;
}
17 changes: 17 additions & 0 deletions src/main/java/ch/fhnw/deardevbackend/dto/insights/InsightDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ch.fhnw.deardevbackend.dto.insights;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.List;

@Data
@AllArgsConstructor
public class InsightDTO {
private List<HappinessInsightDTO> happinessInsights;
private List<WorkKindInsightDTO> workKindInsights;
private List<EmotionInsightDTO> emotionInsights;
private List<WorkKindCountPerDayInsightDTO> workKindCountPerDayInsights;
private double userAverageHappiness;
private double teamAverageHappiness;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ch.fhnw.deardevbackend.dto.insights;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class WorkKindCountPerDayInsightDTO {
private Integer workKindCount;
private Double userAverageHappiness;
private Double teamAverageHappiness;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package ch.fhnw.deardevbackend.dto;
package ch.fhnw.deardevbackend.dto.insights;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class WorkKindInsightDTO {
private Integer teamId;
private Integer workKindId;
private String workKindName;
private Double averageHappiness;
private Long totalCount;
private Double userAverage;
private Long userCount;
private Double teamAverage;
private Long teamCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -21,13 +23,8 @@ public class EmotionSurvey {
private Integer userId;

@Column(name = "submitted", columnDefinition = "TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
private String submitted;
private LocalDateTime submitted;

@Column(name = "emotion_id")
private Integer emotionId;





}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -21,7 +23,7 @@ public class WorkKindSurvey {
private Integer userId;

@Column(name = "submitted", columnDefinition = "TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
private String submitted;
private LocalDateTime submitted;

@Column(name = "score")
private Integer score;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@



import ch.fhnw.deardevbackend.dto.HappinessInsightDTO;
import ch.fhnw.deardevbackend.dto.insights.HappinessInsightDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public interface SubmitEmotionSurveyMapper {
SubmitEmotionSurveyMapper INSTANCE = Mappers.getMapper(SubmitEmotionSurveyMapper.class);

@Mapping(target = "submitted", expression = "java(java.time.OffsetDateTime.now().toString())")
@Mapping(target = "submitted", expression = "java(java.time.LocalDateTime.now())")
EmotionSurvey toEmotionSurvey(SubmitEmotionSurveyDTO dto);
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public interface SubmitWorkKindSurveyMapper {
SubmitWorkKindSurveyMapper INSTANCE = Mappers.getMapper(SubmitWorkKindSurveyMapper.class);

@Mapping(target = "submitted", expression = "java(java.time.OffsetDateTime.now().toString())")
@Mapping(target = "submitted", expression = "java(java.time.LocalDateTime.now())")
WorkKindSurvey toWorkKindSurvey(SubmitWorkKindSurveyDTO dto);
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ch.fhnw.deardevbackend.mapper;

import ch.fhnw.deardevbackend.dto.WorkKindInsightDTO;
import ch.fhnw.deardevbackend.dto.insights.WorkKindInsightDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
Expand All @@ -9,10 +9,23 @@
public interface WorkKindInsightMapper {
WorkKindInsightMapper INSTANCE = Mappers.getMapper(WorkKindInsightMapper.class);

@Mapping(source = "teamId", target = "teamId")
@Mapping(source = "workKindId", target = "workKindId")
@Mapping(source = "workKindName", target = "workKindName")
@Mapping(source = "averageHappiness", target = "averageHappiness")
@Mapping(source = "totalCount", target = "totalCount")
WorkKindInsightDTO toDTO(Integer teamId, Integer workKindId, String workKindName, Double averageHappiness, Long totalCount);
@Mapping(source = "userAverage", target = "userAverage")
@Mapping(source = "userCount", target = "userCount")
@Mapping(source = "teamAverage", target = "teamAverage")
@Mapping(source = "teamCount", target = "teamCount")
WorkKindInsightDTO toDTO(Integer workKindId, String workKindName, Double userAverage, Long userCount, Double teamAverage, Long teamCount);

@Mapping(source = "workKindId", target = "workKindId")
@Mapping(source = "workKindName", target = "workKindName")
@Mapping(source = "userAverage", target = "userAverage")
@Mapping(source = "userCount", target = "userCount")
WorkKindInsightDTO toUserDTO(Integer workKindId, String workKindName, Double userAverage, Long userCount);

@Mapping(source = "workKindId", target = "workKindId")
@Mapping(source = "workKindName", target = "workKindName")
@Mapping(source = "teamAverage", target = "teamAverage")
@Mapping(source = "teamCount", target = "teamCount")
WorkKindInsightDTO toTeamDTO(Integer workKindId, String workKindName, Double teamAverage, Long teamCount);
}
Loading

0 comments on commit 7ed99d3

Please sign in to comment.