Skip to content

Commit

Permalink
change signal uuid after 10 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
cproof committed Feb 20, 2024
1 parent cd809cd commit ea575bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/at/rtr/rmbt/constant/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ public interface Constants {
" AXIS[\"Easting\",EAST],\n" +
" AXIS[\"Northing\",NORTH],\n" +
" AUTHORITY[\"EPSG\",\"900913\"]]";

static final int SIGNAL_CHANGE_UUID_AFTER_MIN = 10;
}
10 changes: 9 additions & 1 deletion src/main/java/at/rtr/rmbt/service/impl/SignalServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import jakarta.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.function.Function;
Expand Down Expand Up @@ -143,8 +144,15 @@ public SignalResultResponse processSignalResult(SignalResultRequest signalResult
testMapper.updateTestLocation(updatedTest);
testRepository.saveAndFlush(updatedTest);

UUID uuidToReturn = updatedTest.getUuid();
if (updatedTest.getTimestamp().plusMinutes(Constants.SIGNAL_CHANGE_UUID_AFTER_MIN)
.compareTo(Instant.now().atZone(updatedTest.getTimestamp().getZone())) > 0) {
log.info("updating signal uuid after " + Constants.SIGNAL_CHANGE_UUID_AFTER_MIN + " minutes");
uuidToReturn = UUID.randomUUID();
}

return SignalResultResponse.builder()
.testUUID(updatedTest.getUuid())
.testUUID(uuidToReturn)
.build();
}

Expand Down

0 comments on commit ea575bd

Please sign in to comment.