Skip to content

Commit 1453120

Browse files
committed
refactor(UtmDataInputStatusService): improve handling of last processed timestamp
1 parent ada9702 commit 1453120

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

backend/src/main/java/com/park/utmstack/service/UtmDataInputStatusService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,14 @@ private Map<String, StatisticDocument> getLatestStatisticsByDataSource() {
485485
}
486486
});
487487

488-
Instant lastTimestamp = result.values().stream()
488+
Optional<Instant> maybeLastTimestamp = result.values().stream()
489489
.map(doc -> Instant.parse(doc.getTimestamp()))
490-
.max(Instant::compareTo)
491-
.orElse(Instant.now());
490+
.max(Instant::compareTo);
492491

493-
checkpoint.setLastProcessedTimestamp(lastTimestamp);
494-
495-
this.checkpointRepository.save(checkpoint);
492+
if (maybeLastTimestamp.isPresent()) {
493+
checkpoint.setLastProcessedTimestamp(maybeLastTimestamp.get());
494+
this.checkpointRepository.save(checkpoint);
495+
}
496496

497497
return result;
498498
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
6+
7+
<changeSet id="20260210009" author="Manuel">
8+
9+
<sql dbms="postgresql" splitStatements="true" stripComments="true">
10+
<![CDATA[
11+
12+
UPDATE utm_data_input_status_checkpoint
13+
SET last_processed_timestamp = NOW() - INTERVAL '12 hours'
14+
WHERE id = 1;
15+
16+
]]>
17+
</sql>
18+
19+
</changeSet>
20+
</databaseChangeLog>

backend/src/main/resources/config/liquibase/master.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@
403403

404404
<include file="/config/liquibase/changelog/20260210008_update_filter_windows_events.xml" relativeToChangelogFile="false"/>
405405

406+
<include file="/config/liquibase/changelog/20260210009_update_data_input_status_checkpoint.xml" relativeToChangelogFile="false"/>
407+
406408

407409

408410
</databaseChangeLog>

0 commit comments

Comments
 (0)