@@ -11,7 +11,7 @@ final class PsqlNotifications {
11
11
12
12
private static final String NOTIFICATION_TABLE_NAME = "notification" ;
13
13
private static final String QUERY = """
14
- SELECT patient_id, id, names, created, state,type, score, golden_id
14
+ SELECT patient_id, id, names, created, state,type, score, old_golden_id, current_golden_id
15
15
FROM notification
16
16
WHERE created BETWEEN ? AND ? AND state IN (?, ?)
17
17
ORDER BY created
@@ -38,6 +38,7 @@ final class PsqlNotifications {
38
38
* @param states The state of notification.
39
39
* @return A {@link MatchesForReviewResult} object containing the matches and related information.
40
40
*/
41
+
41
42
MatchesForReviewResult getMatchesForReview (
42
43
final int limit ,
43
44
final int offset ,
@@ -166,15 +167,21 @@ void insertCandidates(
166
167
}
167
168
}
168
169
169
- void updateNotificationState (
170
- final String id ) throws SQLException {
170
+ void updateNotificationState (final String notificationId , final String oldGoldenId , final String currentGoldenId ) throws SQLException {
171
171
psqlClient .connect ();
172
- try (Statement stmt = psqlClient .createStatement ()) {
173
- ResultSet rs = stmt .executeQuery (String .format (Locale .ROOT ,
174
- "update notification set state = '%s' where id = '%s'" ,
175
- "CLOSED" ,
176
- id ));
177
- psqlClient .commit ();
172
+ String sql = String .format (Locale .ROOT , "update notification set state = '%s', old_golden_id = '%s', current_golden_id = '%s' where id = '%s'" ,
173
+ "CLOSED" ,
174
+ oldGoldenId ,
175
+ currentGoldenId ,
176
+ notificationId );
177
+ try (PreparedStatement stmt = psqlClient .prepareStatement (sql )) {
178
+ int rowsAffected = stmt .executeUpdate ();
179
+ if (rowsAffected > 0 ) {
180
+ LOGGER .info ("Updated notification {} with new currentGoldenId {}" , notificationId , currentGoldenId );
181
+ psqlClient .commit ();
182
+ } else {
183
+ LOGGER .warn ("Notification with ID {} not found" , notificationId );
184
+ }
178
185
}
179
186
}
180
187
0 commit comments