# 2023.11.02

## 할일 및 한일&#x20;

* [x] Wasabi 프로젝트 이미지 로직 리팩토링&#x20;

## 경험 및 배움&#x20;

### Wasabi 프로젝트 이미지 로직 리팩토링&#x20;

오늘은 간단한 작업이지만, 이미지 로직을 리팩토링했다.

**기존에는 불필요한 이미지를 스케줄링을 통해 삭제할 때 스트림을 통해 하나하나 삭제했다.**

**하지만, 그렇게 되면 쿼리가 하나하나 날아갔고, 회의에서 피드백으로 한번에 삭제하는 것이 어떻냐는 의견이 나와 리팩토링을 진행했다.**

**처음에는 JPA에서 제공해주는 `deleteAllByIdInBatch` 를 사용해서 한방 쿼리를 완성했다.**

**하지만, 한방 쿼리는 맞지만 예상한 것과는 달리 쿼리는 `where` 절에서 `or` 을 통해 조건이 여러개 달렸다.**

**따라서, 제공해주는 메서드가 아닌 JPQL을 통해 `in` 절로 한번에 삭제하는 쿼리를 적용했다!**

사소하지만 이런 점들을 하나하나 비교해보고 고민해보고 개선하는 작업이 큰 장점이 된다고 생각한다 👍🏻

{% embed url="<https://github.com/Wisoft-Wasabi/wasabi-backend/pull/133>" %}

## 개선 및 목표&#x20;

* 내일은 무중단 배포 마무리 or 개인 공부!&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jinwon-yoon.gitbook.io/jinonys-blog/daily-log/2023.11.02.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
