Skip to content

Commit

Permalink
refactor: TeumTeumService 리팩토링 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
choidongkuen committed Feb 11, 2024
1 parent 9d3cd04 commit 5a35805
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.teumteum.core.security.service.RedisService;
import net.teumteum.teum_teum.domain.UserLocation;
import net.teumteum.teum_teum.domain.request.UserLocationRequest;
import net.teumteum.teum_teum.domain.response.UserAroundLocationsResponse;
import org.springframework.stereotype.Service;

@Slf4j

@Service
@RequiredArgsConstructor
public class TeumTeumService {

private static final int SEARCH_LIMIT = 6;
private static final long USER_LOCATION_DATA_DURATION = 30L;
private static final long USER_LOCATION_DATA_DURATION = 10L;
private static final int AROUND_USER_LOCATION_DISTANCE = 100;

private final RedisService redisService;

Expand All @@ -37,7 +37,7 @@ private UserAroundLocationsResponse getUserAroundLocations(UserLocationRequest r
Set<UserLocation> aroundUserLocations = allUserLocations.stream()
.filter(userLocation -> !userLocation.id().equals(request.id()))
.filter(userLocation -> calculateDistance(request.latitude(), request.longitude(),
userLocation.latitude(), userLocation.longitude()) <= 100)
userLocation.latitude(), userLocation.longitude()) <= AROUND_USER_LOCATION_DISTANCE)
.sorted(comparingDouble(userLocation
-> calculateDistance(request.latitude(), request.longitude(),
userLocation.latitude(), userLocation.longitude()))
Expand Down

0 comments on commit 5a35805

Please sign in to comment.