-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from 2024-Iris/issue-detail
이슈 상세보기 및 댓글 조회 기능 구현
- Loading branch information
Showing
31 changed files
with
672 additions
and
38 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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/site/iris/issuefy/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,24 @@ | ||
package site.iris.issuefy.controller; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestAttribute; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import site.iris.issuefy.response.DashBoardResponse; | ||
import site.iris.issuefy.service.DashBoardService; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/dashboard") | ||
public class DashBoardController { | ||
private final DashBoardService dashBoardService; | ||
|
||
@GetMapping | ||
public ResponseEntity<DashBoardResponse> dashboard(@RequestAttribute String githubId) { | ||
DashBoardResponse dashBoardResponse = dashBoardService.getDashBoardFromLoki(githubId); | ||
return ResponseEntity.ok().body(dashBoardResponse); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package site.iris.issuefy.eums; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum DashBoardRank { | ||
S(80, "S"), | ||
A(60, "A"), | ||
B(40, "B"), | ||
C(20, "C"), | ||
D(0, "D"); | ||
|
||
private final int threshold; | ||
private final String label; | ||
|
||
public static String getRankLabel(int score) { | ||
for (DashBoardRank rank : values()) { | ||
if (score >= rank.threshold) { | ||
return rank.label; | ||
} | ||
} | ||
return D.label; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package site.iris.issuefy.eums; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum LokiQuery { | ||
NUMBER_OF_WEEKLY_VISIT( | ||
"sum(count_over_time({job=\"issuefylog\"} |= \"[%s]\" |= \"Response: 200 GET /api/login - Method: login \" [6d]))"), | ||
NUMBER_OF_WEEKLY_REPOSITORY_ADDED( | ||
"sum(count_over_time({job=\"issuefylog\"} |= \"[%s]\" |= \"Request: POST /api/subscriptions - Method: addRepository \" [6d]))"); | ||
|
||
private final String query; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/site/iris/issuefy/exception/network/LokiException.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 site.iris.issuefy.exception.network; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class LokiException extends NetworkException { | ||
public LokiException(String message, HttpStatus status) { | ||
super(message, status); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/site/iris/issuefy/model/dto/CommentsDto.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 site.iris.issuefy.model.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class CommentsDto { | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@JsonProperty("user") | ||
private IssueUserDto issueUserDto; | ||
|
||
@JsonProperty("created_at") | ||
private LocalDateTime createdAt; | ||
|
||
@JsonProperty("updated_at") | ||
private LocalDateTime updatedAt; | ||
|
||
@JsonProperty("body") | ||
private String body; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/site/iris/issuefy/model/dto/IssueDetailDto.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,35 @@ | ||
package site.iris.issuefy.model.dto; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class IssueDetailDto { | ||
@JsonProperty("number") | ||
private Long id; | ||
|
||
@JsonProperty("title") | ||
private String title; | ||
|
||
@JsonProperty("state") | ||
private String state; | ||
|
||
@JsonProperty("user") | ||
private IssueUserDto issueUserDto; | ||
|
||
@JsonProperty("created_at") | ||
private LocalDateTime createdAt; | ||
|
||
@JsonProperty("updated_at") | ||
private LocalDateTime updatedAt; | ||
|
||
@JsonProperty("body") | ||
private String body; | ||
|
||
@JsonProperty("labels") | ||
private List<LabelDto> labels; | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/site/iris/issuefy/model/dto/IssueUserDto.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,14 @@ | ||
package site.iris.issuefy.model.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class IssueUserDto { | ||
@JsonProperty("login") | ||
private String githubId; | ||
|
||
@JsonProperty("avatar_url") | ||
private String githubProfileImage; | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/site/iris/issuefy/model/dto/LokiQueryAddRepositoryDto.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,29 @@ | ||
package site.iris.issuefy.model.dto; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class LokiQueryAddRepositoryDto { | ||
private String addRepositoryCount = "0"; | ||
|
||
@JsonProperty("data") | ||
private void unpackData(Data data) { | ||
if (data.getResult() != null && !data.getResult().isEmpty()) { | ||
addRepositoryCount = data.getResult().get(0).getValue().get(1); | ||
} | ||
} | ||
|
||
@lombok.Data | ||
private static class Data { | ||
private List<Result> result; | ||
} | ||
|
||
@lombok.Data | ||
private static class Result { | ||
private List<String> value; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/site/iris/issuefy/model/dto/LokiQueryVisitDto.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,29 @@ | ||
package site.iris.issuefy.model.dto; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class LokiQueryVisitDto { | ||
private String visitCount = "0"; | ||
|
||
@JsonProperty("data") | ||
private void unpackData(Data data) { | ||
if (data.getResult() != null && !data.getResult().isEmpty()) { | ||
visitCount = data.getResult().get(0).getValue().get(1); | ||
} | ||
} | ||
|
||
@lombok.Data | ||
private static class Data { | ||
private List<Result> result; | ||
} | ||
|
||
@lombok.Data | ||
private static class Result { | ||
private List<String> value; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/site/iris/issuefy/response/DashBoardResponse.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,21 @@ | ||
package site.iris.issuefy.response; | ||
|
||
import java.time.LocalDate; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class DashBoardResponse { | ||
private LocalDate startDate; | ||
private LocalDate endDate; | ||
private String rank; | ||
private String visitCount; | ||
private String addRepositoryCount; | ||
|
||
public static DashBoardResponse of(LocalDate startDate, LocalDate endDate, String rank, String visitCount, | ||
String addRepositoryCount) { | ||
return new DashBoardResponse(startDate, endDate, rank, visitCount, addRepositoryCount); | ||
} | ||
} |
Oops, something went wrong.