Skip to content

Commit

Permalink
fixed last edit timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Aug 14, 2017
1 parent ef4c69d commit cf679d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/erudika/scoold/core/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/macro.vm
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
<div>$!lang.get("posts.posted") #formatdate($showpost.timestamp "")</div>
#if ($showpost.lasteditby)
<a href="$revisionslink/$!showpost.id" title="Revision history">
$!lang.get("posts.edited") #formatdate($showpost.updated "")
$!lang.get("posts.edited") #formatdate($showpost.lastedited "")
</a>
#end
</div>
Expand Down

0 comments on commit cf679d1

Please sign in to comment.