Skip to content

Commit

Permalink
fix(search): remove search
Browse files Browse the repository at this point in the history
  • Loading branch information
gracefulBrown committed Mar 8, 2024
1 parent aaf5b46 commit d6fa057
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ Feature: 스터디로그 관련 기능
When "학습log"을 검색하면
Then 10개의 스터디로그를 id의 역순으로 받는다

Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그
Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고
When "학습log"을 검색하고 1번 태그의 스터디로그를 조회하면
Then 7개의 스터디로그 목록을 받는다
# 검색 제거로 임시 스킵
# Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그
# Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고
# When "학습log"을 검색하고 1번 태그의 스터디로그를 조회하면
# Then 7개의 스터디로그 목록을 받는다

Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그 + 미션1
Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
package wooteco.prolog.studylog.application;

import static java.time.temporal.TemporalAdjusters.firstDayOfMonth;
import static java.time.temporal.TemporalAdjusters.lastDayOfMonth;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_ARGUMENT;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -25,7 +9,6 @@
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import wooteco.prolog.common.exception.BadRequestCode;
import wooteco.prolog.common.exception.BadRequestException;
import wooteco.prolog.login.ui.LoginMember;
import wooteco.prolog.member.application.MemberService;
Expand All @@ -37,7 +20,6 @@
import wooteco.prolog.session.domain.Mission;
import wooteco.prolog.session.domain.Session;
import wooteco.prolog.studylog.application.dto.CalendarStudylogResponse;
import wooteco.prolog.studylog.application.dto.StudylogDocumentResponse;
import wooteco.prolog.studylog.application.dto.StudylogMissionRequest;
import wooteco.prolog.studylog.application.dto.StudylogRequest;
import wooteco.prolog.studylog.application.dto.StudylogResponse;
Expand All @@ -61,6 +43,23 @@
import wooteco.prolog.studylog.domain.repository.dto.CommentCount;
import wooteco.prolog.studylog.event.StudylogDeleteEvent;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static java.time.temporal.TemporalAdjusters.firstDayOfMonth;
import static java.time.temporal.TemporalAdjusters.lastDayOfMonth;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_ARGUMENT;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND;
import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION;

@Service
@AllArgsConstructor
@Transactional(readOnly = true)
Expand All @@ -69,7 +68,6 @@ public class StudylogService {
private static final Logger logger = LoggerFactory.getLogger(StudylogService.class);

private final MemberTagService memberTagService;
private final DocumentService studylogDocumentService;
private final MemberService memberService;
private final TagService tagService;
private final SessionService sessionService;
Expand Down Expand Up @@ -152,7 +150,6 @@ private StudylogTemp creteStudylogTemp(Long memberId, StudylogRequest studylogRe

private void onStudylogCreatedEvent(Member foundMember, Tags tags, Studylog createdStudylog) {
memberTagService.registerMemberTag(tags, foundMember);
studylogDocumentService.save(createdStudylog.toStudylogDocument());
}

public StudylogsResponse findStudylogs(StudylogsSearchRequest request, Long memberId,
Expand Down Expand Up @@ -188,37 +185,11 @@ public StudylogsResponse findStudylogs(StudylogsSearchRequest request, Long memb
return StudylogsResponse.of(studylogs, memberId, commentCounts);
}

if (request.getKeyword() == null || request.getKeyword().isEmpty()) {
return findStudylogsWithoutKeyword(request.getSessions(), request.getMissions(),
request.getTags(),
request.getUsernames(), request.getMembers(), request.getStartDate(),
request.getEndDate(),
request.getPageable(), memberId);
}

final StudylogDocumentResponse response = studylogDocumentService.findBySearchKeyword(
request.getKeyword(),
return findStudylogsWithoutKeyword(request.getSessions(), request.getMissions(),
request.getTags(),
request.getMissions(),
request.getSessions(),
request.getUsernames(),
request.getStartDate(),
request.getUsernames(), request.getMembers(), request.getStartDate(),
request.getEndDate(),
request.getPageable()
);

final List<Studylog> studylogs = studylogRepository.findByIdInAndDeletedFalseOrderByIdDesc(
response.getStudylogIds()
);
Map<Long, Long> commentCounts = commentCounts(studylogs);
return StudylogsResponse.of(
studylogs,
response.getTotalSize(),
response.getTotalPage(),
response.getCurrPage(),
memberId,
commentCounts
);
request.getPageable(), memberId);
}

private Map<Long, Long> commentCounts(List<Studylog> studylogs) {
Expand Down Expand Up @@ -393,8 +364,6 @@ public void updateStudylog(Long memberId, Long studylogId, StudylogRequest study
studylog.update(studylogRequest.getTitle(), studylogRequest.getContent(), session, mission,
newTags);
memberTagService.updateMemberTag(originalTags, newTags, foundMember);

studylogDocumentService.update(studylog.toStudylogDocument());
}

@Transactional
Expand Down Expand Up @@ -431,7 +400,6 @@ public void deleteStudylog(Long memberId, Long studylogId) {
studylog.validateBelongTo(memberId);

final Tags tags = tagService.findByStudylogsAndMember(studylog, foundMember);
studylogDocumentService.delete(studylog.toStudylogDocument());
checkScrapedOrRead(memberId, studylogId);
memberTagService.removeMemberTag(tags, foundMember);
studylog.delete();
Expand Down
17 changes: 8 additions & 9 deletions frontend/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import Button from '../Button/Button';
import SearchIcon from '../../assets/images/search_icon.svg';
import { Container } from './SearchBar.styles';
import { css } from '@emotion/react';
import { ChangeEventHandler, FormEventHandler } from 'react';

Expand All @@ -13,12 +10,14 @@ interface SearchBarProps {

const SearchBar = ({ css, onSubmit, onChange, value }: SearchBarProps) => {
return (
<form onSubmit={onSubmit}>
<Container css={css}>
<input type="search" placeholder="검색어를 입력하세요" value={value} onChange={onChange} />
{onSubmit && <Button size="X_SMALL" icon={SearchIcon} type="submit" />}
</Container>
</form>
<div>
</div>
// <form onSubmit={onSubmit}>
// <Container css={css}>
// <input type="search" placeholder="검색어를 입력하세요" value={value} onChange={onChange} />
// {onSubmit && <Button size="X_SMALL" icon={SearchIcon} type="submit" />}
// </Container>
// </form>
);
};

Expand Down

0 comments on commit d6fa057

Please sign in to comment.