Skip to content

Commit

Permalink
Use snapshot's latest result time rather than snapshot's creation tim…
Browse files Browse the repository at this point in the history
…e when creating an annotation (#56093)
  • Loading branch information
przemekwitek authored May 4, 2020
1 parent 7ee0af7 commit 55d85e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ private static ObjectParser<Builder, Void> createParser(boolean ignoreUnknownFie
*/
private final Version minVersion;

/**
* This is model snapshot's creation wall clock time.
* Use {@code latestResultTimeStamp} if you need model time instead.
*/
private final Date timestamp;
private final String description;
private final String snapshotId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ private Annotation createModelSnapshotAnnotation(ModelSnapshot modelSnapshot) {
Messages.getMessage(Messages.JOB_AUDIT_SNAPSHOT_STORED, modelSnapshot.getSnapshotId()),
currentTime,
XPackUser.NAME,
modelSnapshot.getTimestamp(),
modelSnapshot.getTimestamp(),
modelSnapshot.getLatestResultTimeStamp(),
modelSnapshot.getLatestResultTimeStamp(),
jobId,
currentTime,
XPackUser.NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ private static ModelSizeStats createModelSizeStats() {
private static ModelSnapshot createModelSnapshot() {
return new ModelSnapshot.Builder(JOB_ID)
.setSnapshotId(randomAlphaOfLength(12))
.setTimestamp(Date.from(Instant.ofEpochMilli(1000000000)))
.setLatestResultTimeStamp(Date.from(Instant.ofEpochMilli(1000_000_000)))
.setTimestamp(Date.from(Instant.ofEpochMilli(2000_000_000)))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ public void testProcessResult_modelSnapshot() {
AutodetectResult result = mock(AutodetectResult.class);
ModelSnapshot modelSnapshot = new ModelSnapshot.Builder(JOB_ID)
.setSnapshotId("a_snapshot_id")
.setTimestamp(Date.from(Instant.ofEpochMilli(1000000000)))
.setLatestResultTimeStamp(Date.from(Instant.ofEpochMilli(1000_000_000)))
.setTimestamp(Date.from(Instant.ofEpochMilli(2000_000_000)))
.setMinVersion(Version.CURRENT)
.build();
when(result.getModelSnapshot()).thenReturn(modelSnapshot);
Expand All @@ -389,8 +390,8 @@ public void testProcessResult_modelSnapshot() {
"Job model snapshot with id [a_snapshot_id] stored",
Date.from(CURRENT_TIME),
XPackUser.NAME,
modelSnapshot.getTimestamp(),
modelSnapshot.getTimestamp(),
Date.from(Instant.ofEpochMilli(1000_000_000)),
Date.from(Instant.ofEpochMilli(1000_000_000)),
JOB_ID,
Date.from(CURRENT_TIME),
XPackUser.NAME,
Expand Down

0 comments on commit 55d85e5

Please sign in to comment.