Skip to content

Commit

Permalink
[Release] 리뷰미 2.0.6 배포
Browse files Browse the repository at this point in the history
[Release] 리뷰미 2.0.6 배포
  • Loading branch information
donghoony authored Dec 15, 2024
2 parents 4a2cbaf + 35d7530 commit efc7f64
Show file tree
Hide file tree
Showing 27 changed files with 103 additions and 351 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-dev-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
deploy:
name: Deploy via self-hosted runner
needs: build
runs-on: [self-hosted, dev]
runs-on: [self-hosted, dev, oracle]

steps:
- name: Checkout to secret repository
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/backend-prod-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ jobs:
deploy:
name: Deploy via self-hosted runner
needs: build
strategy:
matrix:
runner: [prod-a, prod-b]
runs-on: [ self-hosted, "${{ matrix.runner }}" ]
runs-on: [self-hosted, prod, oracle]

steps:
- name: Checkout to secret repository
Expand Down
2 changes: 1 addition & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
Expand Down
19 changes: 19 additions & 0 deletions backend/src/main/java/reviewme/config/CacheManagerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package reviewme.config;

import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@EnableCaching
public class CacheManagerConfig {

@Profile({"local", "dev", "prod"})
@Bean
public CacheManager cacheManager() {
return new ConcurrentMapCacheManager();
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.springframework.web.servlet.resource.NoResourceFoundException;
import reviewme.global.exception.BadRequestException;
import reviewme.global.exception.DataInconsistencyException;
import reviewme.config.requestlimit.TooManyRequestException;
import reviewme.global.exception.FieldErrorResponse;
import reviewme.global.exception.NotFoundException;
import reviewme.global.exception.UnauthorizedException;
Expand Down Expand Up @@ -51,11 +50,6 @@ public ProblemDetail handleDataConsistencyException(DataInconsistencyException e
return ProblemDetail.forStatusAndDetail(HttpStatus.INTERNAL_SERVER_ERROR, ex.getErrorMessage());
}

@ExceptionHandler(TooManyRequestException.class)
public ProblemDetail handleDuplicateRequestException(TooManyRequestException ex) {
return ProblemDetail.forStatusAndDetail(HttpStatus.TOO_MANY_REQUESTS, ex.getErrorMessage());
}

@ExceptionHandler(Exception.class)
public ProblemDetail handleException(Exception ex) {
log.error("Internal server error has occurred", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface AnswerRepository extends JpaRepository<Answer, Long> {
SELECT a FROM Answer a
JOIN Review r ON a.reviewId = r.id
WHERE r.reviewGroupId = :reviewGroupId AND a.questionId IN :questionIds
ORDER BY r.createdAt DESC
ORDER BY r.createdAt DESC, r.id DESC
LIMIT :limit
""")
List<Answer> findReceivedAnswersByQuestionIds(long reviewGroupId, Collection<Long> questionIds, int limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface ReviewRepository extends JpaRepository<Review, Long> {
@Query("""
SELECT r FROM Review r
WHERE r.reviewGroupId = :reviewGroupId
ORDER BY r.createdAt DESC
ORDER BY r.createdAt DESC, r.id DESC
""")
List<Review> findAllByGroupId(long reviewGroupId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public record ReviewAnswerRequest(
@Nullable
String text
) {
public boolean hasTextAnswer() {
return text != null && !text.isEmpty();

public boolean hasNoText() {
return text == null || text.isBlank();
}

public boolean hasCheckboxAnswer() {
return selectedOptionIds != null && !selectedOptionIds.isEmpty();
public boolean hasNoSelectedOptions() {
return selectedOptionIds == null || selectedOptionIds.isEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package reviewme.review.service.mapper;

import reviewme.template.domain.QuestionType;
import reviewme.review.domain.Answer;
import reviewme.review.service.dto.request.ReviewAnswerRequest;
import reviewme.template.domain.QuestionType;

public interface AnswerMapper {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package reviewme.review.service.mapper;

import org.springframework.stereotype.Component;
import reviewme.template.domain.QuestionType;
import reviewme.review.domain.CheckboxAnswer;
import reviewme.review.service.dto.request.ReviewAnswerRequest;
import reviewme.review.service.exception.CheckBoxAnswerIncludedTextException;
import reviewme.template.domain.QuestionType;

@Component
public class CheckboxAnswerMapper implements AnswerMapper {
Expand All @@ -16,8 +15,8 @@ public boolean supports(QuestionType questionType) {

@Override
public CheckboxAnswer mapToAnswer(ReviewAnswerRequest answerRequest) {
if (answerRequest.text() != null) {
throw new CheckBoxAnswerIncludedTextException(answerRequest.questionId());
if (answerRequest.hasNoSelectedOptions()) {
return null;
}
return new CheckboxAnswer(answerRequest.questionId(), answerRequest.selectedOptionIds());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,10 @@ private List<Answer> getAnswersByQuestionType(ReviewRegisterRequest request) {

private Answer mapRequestToAnswer(Map<Long, Question> questions, ReviewAnswerRequest answerRequest) {
Question question = questions.get(answerRequest.questionId());

if (question == null) {
throw new SubmittedQuestionNotFoundException(answerRequest.questionId());
}

// TODO: 아래 코드를 삭제해야 한다
if (question.isSelectable() && answerRequest.selectedOptionIds() != null && answerRequest.selectedOptionIds().isEmpty()) {
return null;
}
if (!question.isSelectable() && answerRequest.text() != null && answerRequest.text().isEmpty()) {
return null;
}
// END

AnswerMapper answerMapper = answerMapperFactory.getAnswerMapper(question.getQuestionType());
return answerMapper.mapToAnswer(answerRequest);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package reviewme.review.service.mapper;

import org.springframework.stereotype.Component;
import reviewme.template.domain.QuestionType;
import reviewme.review.domain.TextAnswer;
import reviewme.review.service.dto.request.ReviewAnswerRequest;
import reviewme.review.service.exception.TextAnswerIncludedOptionItemException;
import reviewme.template.domain.QuestionType;

@Component
public class TextAnswerMapper implements AnswerMapper {
Expand All @@ -16,12 +15,9 @@ public boolean supports(QuestionType questionType) {

@Override
public TextAnswer mapToAnswer(ReviewAnswerRequest answerRequest) {
if (!answerRequest.hasTextAnswer()) {
if (answerRequest.hasNoText()) {
return null;
}
if (answerRequest.selectedOptionIds() != null) {
throw new TextAnswerIncludedOptionItemException(answerRequest.questionId());
}
return new TextAnswer(answerRequest.questionId(), answerRequest.text());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import reviewme.template.domain.OptionGroup;
import reviewme.template.domain.OptionItem;
Expand All @@ -14,17 +15,17 @@
import reviewme.template.domain.SectionQuestion;
import reviewme.template.domain.Template;
import reviewme.template.domain.TemplateSection;
import reviewme.template.service.exception.MissingOptionItemsInOptionGroupException;
import reviewme.template.service.exception.SectionInTemplateNotFoundException;
import reviewme.template.service.exception.TemplateNotFoundByReviewGroupException;
import reviewme.template.repository.SectionRepository;
import reviewme.template.repository.TemplateRepository;
import reviewme.template.service.dto.response.OptionGroupResponse;
import reviewme.template.service.dto.response.OptionItemResponse;
import reviewme.template.service.dto.response.QuestionResponse;
import reviewme.template.service.dto.response.SectionResponse;
import reviewme.template.service.dto.response.TemplateResponse;
import reviewme.template.service.exception.MissingOptionItemsInOptionGroupException;
import reviewme.template.service.exception.QuestionInSectionNotFoundException;
import reviewme.template.service.exception.SectionInTemplateNotFoundException;
import reviewme.template.service.exception.TemplateNotFoundByReviewGroupException;

@Component
@RequiredArgsConstructor
Expand All @@ -38,6 +39,7 @@ public class TemplateMapper {
private final OptionGroupRepository optionGroupRepository;
private final OptionItemRepository optionItemRepository;

@Cacheable(value = "template_response", key = "#reviewGroup.templateId")
public TemplateResponse mapToTemplateResponse(ReviewGroup reviewGroup) {
Template template = templateRepository.findById(reviewGroup.getTemplateId())
.orElseThrow(() -> new TemplateNotFoundByReviewGroupException(
Expand Down
6 changes: 0 additions & 6 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,3 @@ cors:
allowed-origins:
- http://localhost
- https://localhost

request-limit:
threshold: 3
duration: 1s
host: localhost
port: 6379
6 changes: 0 additions & 6 deletions backend/src/main/resources/ports.yml

This file was deleted.

Loading

0 comments on commit efc7f64

Please sign in to comment.