From cf679d19d4f3e1df60f5095857090dd5768886b4 Mon Sep 17 00:00:00 2001 From: Alex Bogdanovski Date: Tue, 15 Aug 2017 01:20:47 +0300 Subject: [PATCH] fixed last edit timestamp --- .../scoold/controllers/QuestionController.java | 3 ++- src/main/java/com/erudika/scoold/core/Post.java | 12 ++++++++++++ src/main/resources/templates/macro.vm | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/erudika/scoold/controllers/QuestionController.java b/src/main/java/com/erudika/scoold/controllers/QuestionController.java index 9c862af2..e02cd4fc 100755 --- a/src/main/java/com/erudika/scoold/controllers/QuestionController.java +++ b/src/main/java/com/erudika/scoold/controllers/QuestionController.java @@ -139,9 +139,10 @@ public String edit(@PathVariable String id, @RequestParam(required = false) Stri showPost.setTags(Arrays.asList(StringUtils.split(tags, ","))); } - showPost.setLasteditby(authUser.getId()); //note: update only happens if something has changed if (!showPost.equals(beforeUpdate)) { + showPost.setLasteditby(authUser.getId()); + showPost.setLastedited(System.currentTimeMillis()); showPost.update(); utils.addBadgeOnceAndUpdate(authUser, Badge.EDITOR, true); } diff --git a/src/main/java/com/erudika/scoold/core/Post.java b/src/main/java/com/erudika/scoold/core/Post.java index 09263ad3..47c6250f 100755 --- a/src/main/java/com/erudika/scoold/core/Post.java +++ b/src/main/java/com/erudika/scoold/core/Post.java @@ -58,6 +58,7 @@ public abstract class Post extends Sysprop { @Stored private String revisionid; @Stored private String closerid; @Stored private Long answercount; + @Stored private Long lastedited; @Stored private String lasteditby; @Stored private String deletereportid; @Stored private String location; @@ -78,6 +79,17 @@ private ParaClient client() { return ScooldUtils.getInstance().getParaClient(); } + public Long getLastedited() { + if (lastedited == null || lastedited <= 0) { + lastedited = getUpdated(); + } + return lastedited; + } + + public void setLastedited(Long lastedited) { + this.lastedited = lastedited; + } + public Pager getItemcount() { if (itemcount == null) { itemcount = new Pager(5); diff --git a/src/main/resources/templates/macro.vm b/src/main/resources/templates/macro.vm index 12a5ca74..20c3ab0c 100755 --- a/src/main/resources/templates/macro.vm +++ b/src/main/resources/templates/macro.vm @@ -385,7 +385,7 @@
$!lang.get("posts.posted") #formatdate($showpost.timestamp "")
#if ($showpost.lasteditby) - $!lang.get("posts.edited") #formatdate($showpost.updated "") + $!lang.get("posts.edited") #formatdate($showpost.lastedited "") #end