Skip to content

Commit

Permalink
[Release] 리뷰미 v2.0.5 배포
Browse files Browse the repository at this point in the history
- 하이라이트 관련 버그 수정
- 하이라이트 리팩토링
  • Loading branch information
skylar1220 authored Nov 19, 2024
2 parents b82137a + 90646b6 commit 4a2cbaf
Show file tree
Hide file tree
Showing 107 changed files with 616 additions and 581 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* @chysis @BadaHertz52 @soosoo22 @ImxYJL @donghoony @Kimprodp @nayonsoso @skylar1220
/frontend/ @chysis @BadaHertz52 @soosoo22 @ImxYJL
/backend/ @donghoony @Kimprodp @nayonsoso @skylar1220
2 changes: 1 addition & 1 deletion .github/workflows/discord-pull-request-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
elif [ "$PR_PREFIX" = '[FE]' ]; then
echo Frontend PR Found!
echo "PR_PREFIX=FE" >> $GITHUB_ENV
elif [ "$PR_PREFIX" = '[All]' ]; then
elif [ "$PR_PREFIX" = '[All]' ] || [ "$PR_PREFIX" = '[Release]' ]; then
echo All PR Found!
echo "PR_PREFIX=All" >> $GITHUB_ENV
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/discord-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
elif [ "$PR_PREFIX" = '[FE]' ]; then
echo Frontend PR Found!
echo "PR_PREFIX=FE" >> $GITHUB_ENV
elif [ "$PR_PREFIX" = '[All]' ]; then
elif [ "$PR_PREFIX" = '[All]' ] || [ "$PR_PREFIX" = '[Release]' ]; then
echo All PR Found!
echo "PR_PREFIX=All" >> $GITHUB_ENV
fi
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
### 백엔드
<p align="center"><img src="https://github.com/user-attachments/assets/0a7aa302-b737-496d-9fec-54a8088da3b5" width="600px"/></p>

### Infrastructure
<p align=center><img src=https://github.com/user-attachments/assets/ea1c3226-f452-4910-9a90-11a9d3e1e1df width=800px/></p>

## 🧑‍💻 팀원 소개

### 프론트엔드
Expand All @@ -59,3 +62,4 @@
| <img src="https://review-me-blog.github.io/assets/images/sancho-a505ff332869b4eda5a1fa6cf296ddc8.jpeg" width="120px" max-height="120px"> | <img src="https://review-me-blog.github.io/assets/images/aru-f1f92d2d3284aab8aa385afd817d2ae7.jpeg" width="120px" max-height="120px"> | <img src="https://review-me-blog.github.io/assets/images/kirby-c5c179939bc7a2fd587bcc2cbb6af129.png" width="120px" max-height="120px"> | <img src="https://review-me-blog.github.io/assets/images/ted-a4f788b021e7619d4cc9ae7fc0ab336d.png" width="120px" max-height="120px"> |
| :---: | :---: | :---: | :---: |
| [🦧 산초](https://github.com/nayonsoso) | [🤸🏻‍♂️ 아루](https://github.com/donghoony) | [💃 커비](https://github.com/skylar1220) | [🐻 테드](https://github.com/Kimprodp) |

16 changes: 8 additions & 8 deletions backend/src/main/java/reviewme/DatabaseInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import reviewme.question.domain.OptionGroup;
import reviewme.question.domain.OptionItem;
import reviewme.question.domain.OptionType;
import reviewme.question.domain.Question;
import reviewme.question.domain.QuestionType;
import reviewme.question.repository.OptionGroupRepository;
import reviewme.question.repository.OptionItemRepository;
import reviewme.question.repository.QuestionRepository;
import reviewme.template.domain.OptionGroup;
import reviewme.template.domain.OptionItem;
import reviewme.template.domain.OptionType;
import reviewme.template.domain.Question;
import reviewme.template.domain.QuestionType;
import reviewme.template.repository.OptionGroupRepository;
import reviewme.template.repository.OptionItemRepository;
import reviewme.template.repository.QuestionRepository;
import reviewme.template.domain.Section;
import reviewme.template.domain.Template;
import reviewme.template.domain.VisibleType;
Expand Down
10 changes: 0 additions & 10 deletions backend/src/main/java/reviewme/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import reviewme.global.RequestLimitInterceptor;
import reviewme.reviewgroup.controller.ReviewGroupSessionResolver;
import reviewme.reviewgroup.service.ReviewGroupService;

Expand All @@ -16,16 +13,9 @@
public class WebConfig implements WebMvcConfigurer {

private final ReviewGroupService reviewGroupService;
private final RedisTemplate<String, Long> redisTemplate;
private final RequestLimitProperties requestLimitProperties;

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new ReviewGroupSessionResolver(reviewGroupService));
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new RequestLimitInterceptor(redisTemplate, requestLimitProperties));
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package reviewme.config;
package reviewme.config.cors;

import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
public class CorsConfig {

private static final Logger log = LoggerFactory.getLogger(CorsConfig.class);

private CorsConfig() {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.config;
package reviewme.config.cors;

import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.config;
package reviewme.config.datasource;

public enum DataSourceType {
READ,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.config;
package reviewme.config.datasource;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -54,4 +54,3 @@ public DataSource dataSource(@Qualifier(ROUTING_DATA_SOURCE_NAME) DataSource rou
return new LazyConnectionDataSourceProxy(routingDataSource);
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.config;
package reviewme.config.datasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import org.springframework.transaction.support.TransactionSynchronizationManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.global;
package reviewme.config.requestlimit;

import static org.springframework.http.HttpHeaders.USER_AGENT;

Expand All @@ -11,8 +11,6 @@
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import reviewme.config.RequestLimitProperties;
import reviewme.global.exception.TooManyRequestException;

@Component
@EnableConfigurationProperties(RequestLimitProperties.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package reviewme.config;
package reviewme.config.requestlimit;

import java.time.Duration;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "request-limit")
public record RequestLimitProperties(
long threshold,
Duration duration,
String host,
int port
) {
public record RequestLimitProperties(long threshold, Duration duration, String host, int port) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.config;
package reviewme.config.requestlimit;

import lombok.RequiredArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package reviewme.config.requestlimit;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class RequestLimitWebConfig implements WebMvcConfigurer {

private final RedisTemplate<String, Long> redisTemplate;
private final RequestLimitProperties requestLimitProperties;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new RequestLimitInterceptor(redisTemplate, requestLimitProperties));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package reviewme.global.exception;
package reviewme.config.requestlimit;

import lombok.extern.slf4j.Slf4j;
import reviewme.global.exception.ReviewMeException;

@Slf4j
public class TooManyRequestException extends ReviewMeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.springframework.web.servlet.resource.NoResourceFoundException;
import reviewme.global.exception.BadRequestException;
import reviewme.global.exception.DataInconsistencyException;
import reviewme.global.exception.TooManyRequestException;
import reviewme.config.requestlimit.TooManyRequestException;
import reviewme.global.exception.FieldErrorResponse;
import reviewme.global.exception.NotFoundException;
import reviewme.global.exception.UnauthorizedException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
package reviewme.global.exception;

public record FieldErrorResponse(
String field,
Object value,
String message
) {
public record FieldErrorResponse(String field, Object value, String message) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.IntStream;
import lombok.Getter;
import reviewme.highlight.domain.exception.InvalidHighlightLineIndexException;
import reviewme.highlight.domain.exception.NegativeHighlightLineIndexException;
Expand Down Expand Up @@ -37,4 +39,12 @@ private void validateLineIndexRange(int lineIndex) {
throw new InvalidHighlightLineIndexException(lineIndex, lines.size());
}
}

public List<Highlight> toHighlights(long answerId) {
return IntStream.range(0, lines.size())
.mapToObj(lineIndex -> lines.get(lineIndex).getRanges().stream()
.map(range -> new Highlight(answerId, lineIndex, range)))
.flatMap(Function.identity())
.toList();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package reviewme.highlight.repository;

import java.util.Collection;
import reviewme.highlight.domain.Highlight;

public interface HighlightJdbcRepository {

void saveAll(Collection<Highlight> highlights);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package reviewme.highlight.repository;

import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import reviewme.highlight.domain.Highlight;

@RequiredArgsConstructor
public class HighlightJdbcRepositoryImpl implements HighlightJdbcRepository {

private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;

@Override
public void saveAll(Collection<Highlight> highlights) {
SqlParameterSource[] parameterSources = SqlParameterSourceUtils.createBatch(highlights.toArray());
String insertSql = """
INSERT INTO highlight (answer_id, line_index, start_index, end_index)
VALUES (:answerId, :lineIndex, :highlightRange.startIndex, :highlightRange.endIndex)
""";
namedParameterJdbcTemplate.batchUpdate(insertSql, parameterSources);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,32 @@

import java.util.Collection;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import reviewme.highlight.domain.Highlight;

public interface HighlightRepository extends JpaRepository<Highlight, Long> {
public interface HighlightRepository extends Repository<Highlight, Long>, HighlightJdbcRepository {

@Modifying
@Query("""
DELETE FROM Highlight h
WHERE h.answerId IN :answerIds
""")
void deleteAllByAnswerIds(Collection<Long> answerIds);
Highlight save(Highlight highlight);

boolean existsById(long id);

@Query("""
SELECT h
FROM Highlight h
SELECT h FROM Highlight h
WHERE h.answerId IN :answerIds
ORDER BY h.lineIndex, h.highlightRange.startIndex ASC
""")
List<Highlight> findAllByAnswerIdsOrderedAsc(Collection<Long> answerIds);

@Modifying
@Query("""
DELETE FROM Highlight h
WHERE h.answerId IN (
SELECT a.id FROM Answer a
JOIN Review r ON a.reviewId = r.id
WHERE r.reviewGroupId = :reviewGroupId AND a.questionId = :questionId
)
""")
void deleteByReviewGroupIdAndQuestionId(long reviewGroupId, long questionId);
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
package reviewme.highlight.service;

import java.util.List;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import reviewme.highlight.domain.Highlight;
import reviewme.highlight.repository.HighlightRepository;
import reviewme.highlight.service.dto.HighlightsRequest;
import reviewme.highlight.service.mapper.HighlightMapper;
import reviewme.highlight.service.validator.HighlightValidator;
import reviewme.review.repository.AnswerRepository;
import reviewme.review.service.validator.AnswerValidator;
import reviewme.reviewgroup.domain.ReviewGroup;

@Service
@RequiredArgsConstructor
public class HighlightService {

private final HighlightRepository highlightRepository;
private final AnswerRepository answerRepository;

private final HighlightValidator highlightValidator;
private final HighlightMapper highlightMapper;
private final AnswerValidator answerValidator;

@Transactional
public void editHighlight(HighlightsRequest highlightsRequest, ReviewGroup reviewGroup) {
highlightValidator.validate(highlightsRequest, reviewGroup);
List<Highlight> highlights = highlightMapper.mapToHighlights(highlightsRequest);

Set<Long> answerIds = answerRepository.findIdsByQuestionId(highlightsRequest.questionId());
highlightRepository.deleteAllByAnswerIds(answerIds);
List<Long> requestedAnswerIds = highlightsRequest.getUniqueAnswerIds();
answerValidator.validateQuestionContainsAnswers(highlightsRequest.questionId(), requestedAnswerIds);
answerValidator.validateReviewGroupContainsAnswers(reviewGroup, requestedAnswerIds);

List<Highlight> highlights = highlightMapper.mapToHighlights(highlightsRequest);
highlightRepository.deleteByReviewGroupIdAndQuestionId(reviewGroup.getId(), highlightsRequest.questionId());
highlightRepository.saveAll(highlights);
}
}
Loading

0 comments on commit 4a2cbaf

Please sign in to comment.