Skip to content

Commit

Permalink
refactor: reply creation time
Browse files Browse the repository at this point in the history
  • Loading branch information
guqing committed Mar 13, 2024
1 parent 0f76008 commit 17fe4e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -45,6 +45,12 @@ public Result reconcile(Request request) {
eventPublisher.publishEvent(new ReplyCreatedEvent(this, reply));
}

var creationTime = reply.getSpec().getCreationTime();
if (creationTime == null) {
reply.getSpec().setCreationTime(reply.getMetadata().getCreationTimestamp());
}
client.update(reply);

replyNotificationSubscriptionHelper.subscribeNewReplyReasonForReply(reply);

eventPublisher.publishEvent(new ReplyChangedEvent(this, reply));
Expand Down
Expand Up @@ -223,7 +223,8 @@ public void onApplicationEvent(@NonNull ApplicationContextInitializedEvent event
indexSpecs.add(new IndexSpec()
.setName("spec.creationTime")
.setIndexFunc(simpleAttribute(Comment.class,
comment -> comment.getSpec().getCreationTime().toString())
comment -> defaultIfNull(comment.getSpec().getCreationTime(),
comment.getMetadata().getCreationTimestamp()).toString())
));
indexSpecs.add(new IndexSpec()
.setName("spec.approved")
Expand Down Expand Up @@ -286,7 +287,8 @@ public void onApplicationEvent(@NonNull ApplicationContextInitializedEvent event
indexSpecs.add(new IndexSpec()
.setName("spec.creationTime")
.setIndexFunc(simpleAttribute(Reply.class,
reply -> reply.getSpec().getCreationTime().toString())
reply -> defaultIfNull(reply.getSpec().getCreationTime(),
reply.getMetadata().getCreationTimestamp()).toString())
));
indexSpecs.add(new IndexSpec()
.setName("spec.commentName")
Expand Down

0 comments on commit 17fe4e8

Please sign in to comment.