Skip to content

Commit

Permalink
[IDLE-509] 크롤링 전체 조회 시, 공고가 중복 노출되는 현상 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou committed Nov 9, 2024
1 parent 1a442a5 commit baca242
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ class CrawlingJobPostingService(
}

fun findAllByCarerLocationInRange(
carerId: UUID,
location: Point,
next: UUID?,
limit: Long,
): List<CrawlingJobPostingPreviewDto> {
return crawlingJobPostingSpatialQueryRepository.findAllInRange(
carerId = carerId,
location = location,
next = next,
limit = limit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.swm.idle.domain.jobposting.enums.PayType
import com.swm.idle.domain.jobposting.repository.jpa.JobPostingJpaRepository
import com.swm.idle.domain.jobposting.repository.querydsl.JobPostingQueryRepository
import com.swm.idle.domain.jobposting.repository.querydsl.JobPostingSpatialQueryRepository
import com.swm.idle.domain.user.carer.entity.jpa.Carer
import com.swm.idle.domain.user.common.enum.GenderType
import com.swm.idle.domain.user.common.vo.BirthYear
import org.locationtech.jts.geom.Point
Expand Down Expand Up @@ -195,13 +194,13 @@ class JobPostingService(
}

fun findAllByCarerLocationInRange(
carer: Carer,
carerId: UUID,
location: Point,
next: UUID?,
limit: Long,
): List<JobPostingPreviewDto> {
return jobPostingSpatialQueryRepository.findAllWithWeekdaysInRange(
carer = carer,
carerId = carerId,
location = location,
next = next,
limit = limit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,17 @@ class CarerJobPostingFacadeService(
}

val jobPostingPreviewDtos = jobPostingService.findAllByCarerLocationInRange(
carer = carer,
carerId = carer.id,
location = location,
next = next,
limit = limit + 1,
)


val carerLocation = PointConverter.convertToPoint(
latitude = carer.latitude.toDouble(),
longitude = carer.longitude.toDouble(),
)


for (jobPostingPreviewDto in jobPostingPreviewDtos) {
jobPostingPreviewDto.distance = jobPostingService.calculateDistance(
jobPostingPreviewDto.jobPosting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ class CrawlingJobPostingFacadeService(
next: UUID?,
limit: Long,
): Pair<List<CrawlingJobPostingPreviewDto>, UUID?> {
val carer = getUserAuthentication().userId.let {
carerService.getById(it)
}

val crawlingJobPostingPreviewDtos = crawlingJobPostingService.findAllByCarerLocationInRange(
carerId = carer.id,
location = location,
next = next,
limit = limit + 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CrawlingJobPostingSpatialQueryRepository(
) {

fun findAllInRange(
carerId: UUID,
location: Point,
next: UUID?,
limit: Long,
Expand All @@ -41,8 +42,11 @@ class CrawlingJobPostingSpatialQueryRepository(
return jpaQueryFactory
.select(crawledJobPosting, jobPostingFavorite)
.from(crawledJobPosting)
.leftJoin(jobPostingFavorite).fetchJoin()
.on(crawledJobPosting.id.eq(jobPostingFavorite.jobPostingId))
.leftJoin(jobPostingFavorite)
.on(
crawledJobPosting.id.eq(jobPostingFavorite.jobPostingId)
.and(jobPostingFavorite.carerId.eq(carerId))
)
.where(crawledJobPosting.id.`in`(crawledJobPostingIds))
.transform(
groupBy(crawledJobPosting.id)
Expand All @@ -61,7 +65,7 @@ class CrawlingJobPostingSpatialQueryRepository(
location: Point,
): BooleanExpression {
return Expressions.booleanTemplate(
"ST_Contains(ST_BUFFER({0}, 3000), {1})",
"ST_Contains(ST_BUFFER({0}, 5000), {1})",
location,
crawledJobPosting.location,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.swm.idle.domain.jobposting.entity.jpa.QJobPosting.jobPosting
import com.swm.idle.domain.jobposting.entity.jpa.QJobPostingFavorite.jobPostingFavorite
import com.swm.idle.domain.jobposting.entity.jpa.QJobPostingWeekday.jobPostingWeekday
import com.swm.idle.domain.jobposting.enums.JobPostingStatus
import com.swm.idle.domain.user.carer.entity.jpa.Carer
import org.locationtech.jts.geom.Point
import org.springframework.stereotype.Repository
import java.util.*
Expand All @@ -24,7 +23,7 @@ class JobPostingSpatialQueryRepository(
) {

fun findAllWithWeekdaysInRange(
carer: Carer,
carerId: UUID,
location: Point,
next: UUID?,
limit: Long,
Expand Down Expand Up @@ -58,7 +57,7 @@ class JobPostingSpatialQueryRepository(
.leftJoin(applys)
.on(
jobPosting.id.eq(applys.jobPostingId)
.and(applys.carerId.eq(carer.id))
.and(applys.carerId.eq(carerId))
)
.leftJoin(jobPostingFavorite)
.on(jobPosting.id.eq(jobPostingFavorite.jobPostingId))
Expand Down Expand Up @@ -86,7 +85,7 @@ class JobPostingSpatialQueryRepository(
location: Point,
): BooleanExpression {
return Expressions.booleanTemplate(
"ST_Contains(ST_BUFFER({0}, 3000), {1})",
"ST_Contains(ST_BUFFER({0}, 5000), {1})",
location,
jobPosting.location,
)
Expand Down

0 comments on commit baca242

Please sign in to comment.