Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions tracky-emulator/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ server:
port: 8081

url:
hub-service: "http://localhost:8082/hub/car" # 로컬 환경 URL
# hub-service: "http://hub-service.hub1:8082/hub/care" # 개발 환경 URL
# consumer-service: "http://localhost:8083/consume"
# consumer-service: "http://"
# hub-service: "http://localhost:8082/hub/car" # 로컬 환경 URL
hub-service: "http://hub-service.hub1:8082/hub/car" # 개발 환경 URL
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import org.springframework.stereotype.Repository;

import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;

import kernel360.trackycore.core.domain.entity.CarEntity;
Expand All @@ -24,12 +22,14 @@ public class CarDomainRepositoryCustomImpl implements CarDomainRepositoryCustom
@Override
public List<CarEntity> availableRent() {
LocalDateTime now = LocalDateTime.now();

return queryFactory
.select(carEntity)
.from(carEntity)
.leftJoin(rentEntity).on(rentEntity.car.eq(carEntity)
.and(rentEntity.rentStime.lt(now))
.and(rentEntity.rentEtime.gt(now)))
.join(rentEntity).on(
rentEntity.car.eq(carEntity),
rentEntity.rentEtime.goe(now)
)
.fetch();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import kernel360.trackyweb.statistic.application.dto.internal.OperationTime;
import kernel360.trackyweb.statistic.application.dto.internal.TotalCarCount;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Repository
@RequiredArgsConstructor
public class DailyStatisticRepositoryCustomImpl implements DailyStatisticRepositoryCustom {
Expand Down Expand Up @@ -110,8 +112,8 @@ public List<OperationDistance> findSumOperationDistance(LocalDate targetDate) {

@Override
public List<Integer> findDriveCountByBizUuid(String bizUuid) {
LocalDate today = LocalDate.now();
LocalDate startOfMonth = today.withDayOfMonth(1);
LocalDate yesterday = LocalDate.now().minusDays(1);
LocalDate startOfMonth = yesterday.withDayOfMonth(1);

// 1. DB에서 실제 데이터 조회
Map<LocalDate, Integer> driveCountMap = queryFactory
Expand All @@ -122,7 +124,7 @@ public List<Integer> findDriveCountByBizUuid(String bizUuid) {
.from(dailyStatisticEntity)
.where(
dailyStatisticEntity.biz.bizUuid.eq(bizUuid),
dailyStatisticEntity.date.between(startOfMonth, today)
dailyStatisticEntity.date.between(startOfMonth, yesterday)
)
.fetch()
.stream()
Expand All @@ -132,8 +134,10 @@ public List<Integer> findDriveCountByBizUuid(String bizUuid) {
));

// 2. 결과 리스트 생성 (날짜 순서대로)
return startOfMonth.datesUntil(today.plusDays(1))
List<Integer> result = startOfMonth.datesUntil(yesterday.plusDays(1))
.map(date -> driveCountMap.getOrDefault(date, 0))
.collect(Collectors.toList());

return result;
}
}

This file was deleted.

This file was deleted.