-
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 #32 from selab-hs/develop
release v1.0.5
- Loading branch information
Showing
14 changed files
with
141 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
version='1.0.5-SNAPSHOT' | ||
version='1.0.5' | ||
|
9 changes: 9 additions & 0 deletions
9
src/main/java/com/urlshortener/actionlog/repository/SystemActionLogCustomRepository.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 com.urlshortener.actionlog.repository; | ||
|
||
import com.urlshortener.actionlog.domain.SystemActionLog; | ||
|
||
import java.util.List; | ||
|
||
public interface SystemActionLogCustomRepository { | ||
List<SystemActionLog> findNullMemberIdLogsLimitedTo1000(); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/urlshortener/actionlog/repository/SystemActionLogCustomRepositoryImpl.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 com.urlshortener.actionlog.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.urlshortener.actionlog.domain.SystemActionLog; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
import static com.urlshortener.actionlog.domain.QSystemActionLog.systemActionLog; | ||
|
||
@Repository | ||
@AllArgsConstructor | ||
public class SystemActionLogCustomRepositoryImpl implements SystemActionLogCustomRepository { | ||
private final JPAQueryFactory query; | ||
|
||
@Override | ||
public List<SystemActionLog> findNullMemberIdLogsLimitedTo1000() { | ||
return query.selectFrom(systemActionLog) | ||
.where(systemActionLog.memberId.isNull()) | ||
.limit(1000) | ||
.fetch(); | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
src/main/java/com/urlshortener/config/database/QueryDslConfig.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,18 @@ | ||
package com.urlshortener.config.database; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class QueryDslConfig { | ||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/java/com/urlshortener/shortener/repository/ShortUrlCustomRepository.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,5 @@ | ||
package com.urlshortener.shortener.repository; | ||
|
||
public interface ShortUrlCustomRepository { | ||
void updateShortenerUrlMemberId(String uuid, Long memberId); | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/urlshortener/shortener/repository/ShortUrlCustomRepositoryImpl.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,43 @@ | ||
package com.urlshortener.shortener.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.urlshortener.shortener.domain.QShortUrl; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class ShortUrlCustomRepositoryImpl implements ShortUrlCustomRepository { | ||
|
||
private final JPAQueryFactory query; | ||
|
||
@Override | ||
@Transactional | ||
public void updateShortenerUrlMemberId(String uuid, Long memberId) { | ||
final int batchSize = 1000; | ||
long lastId = 0; | ||
List<Long> ids; | ||
|
||
do { | ||
ids = query.select(QShortUrl.shortUrl.id) | ||
.from(QShortUrl.shortUrl) | ||
.where(QShortUrl.shortUrl.uuid.eq(uuid) | ||
.and(QShortUrl.shortUrl.id.gt(lastId))) | ||
.orderBy(QShortUrl.shortUrl.id.asc()) | ||
.limit(batchSize) | ||
.fetch(); | ||
|
||
if (!ids.isEmpty()) { | ||
query.update(QShortUrl.shortUrl) | ||
.where(QShortUrl.shortUrl.id.in(ids)) | ||
.set(QShortUrl.shortUrl.memberId, memberId) | ||
.execute(); | ||
|
||
lastId = ids.get(ids.size() - 1); // Update last processed id | ||
} | ||
} while (ids.size() == batchSize); // 마지막 배치가 최대 크기에 도달했을 때 반복 | ||
} | ||
} |
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