UPDATE: Changing timestamp through UI

(Abdul Munim Zahid) #1

We have a situation in our Forum where we need to change the timestamp of around 350-400 posts!
While this can be done via the rails console, I think its about time Discourse get a simple button in the UI to change timestamp on posts.

I think such power should only be in the hands of the admin and so at the moment i think a good place for adding “Change timestamp” button will be in the menu which opens up when you select a post:

Go to a topic as the admin
Click the wrench icon
Click "Select Posts…"
Select a post and you get the option to change its timestamp

Since there is a counter which counts the number of posts, we can restrict the change timestamp button to only show up when one post is selected?

My initial plan is that we will fork discourse and edit the code for ourselves. Not sure if Discourse wants such a feature? If they will be willing to accept a PR?

Anyways, im here for suggestion, tips!
Any suggestion for a better place in UI?
Im currently studying the discourse source code, so i will begin my work by the day after tomorrow.

And of course if anyone wants to volunteer their help, that would be awesome too!

Schedule posts/topic?
(Kane York) #2

This (and Change Ownership, too) should actually be in the post wrench menu.

(Jeff Atwood) #3

Well, ideally they would be in both places. But definitely both.

(Abdul Munim Zahid) #4

Talking about this wrench button, right?

Something like this:

(Abdul Munim Zahid) #7

Good point! I just deleted it.

Btw, the backdating feature has been working pretty well for me!
Im not sure if others want such a feature too,
Would you guys want a PR?

(pjv) #10

would it be possible to turn this functionality into a plugin? i would really like to add this to my discourse app today.

(Jeff Atwood) #11

I agree this would be nice to have, @techapj can you put it on your list? Low priority.

(Abdul Munim Zahid) #12

When i implemented this feature, i sent a pull request but due to personal issues and lack of time; i wasnt able to make the changes eviltrout suggested.
Also, since i personally am using my own repo i didn’t need it that much either!

However, it will be nice to have this feature in the main discourse repo. Also im willing to help if anyone wants to do these changes ( FEATURE: Changing timestamp through UI by AayEmmZee · Pull Request #3556 · discourse/discourse · GitHub ) and get this pulled.
My code is over here: Commits · AayEmmZee/discourse · GitHub

Also i am willing to gift anyone $50 who gets this pulled for me :smile:

oh and @sam ; thought i would tag you because you were under the impression that this wasnt discussed in meta.

(Jeff Atwood) #13

You should talk to @tgxworld :wink:

I agree a “change timestamp on post” is highly complimentary to “change owner of post” that @riking already worked on.

(Alan Tan) #14


I started working on the feature but there are a few details that I need to clarify before moving on.

  • If first post is selected, should the timestamp of the topic and all the other posts in the topic be changed to the new timestamp? (My opinion is that it should)

  • If a numbered 5 post is selected, should all posts numbered above 5 be changed to the new timestamp or should we just reorder the posts? (I’m not sure on this one)

Do let me know if I missed out on any conditions too :smile_cat:

(Jeff Atwood) #15

Hmm, why would changing the timestamp on one post imply you are changing all the others? This could be very weird.

(Sam Saffron) #16

I am pretty sure stuff will get real odd if you have one posts out of time order in the stream. Stuff may break possibly.

(Alan Tan) #17

I’ll try to explain my thought process. :smiley:

Scenario 1

1 . First post changed.
2. Topic timestamp has to change.
3. If new timestamp is earlier than the current timestamp, we will just change the timestamp of the first post.
4. If new timestamp is later than the timestamp of the next post, we could either reorder the posts || disallow any timestamp that is later than the next post || update the timestamp of all the posts.

Scenario 2

  1. Post numbered 5 changed.
  2. If new timestamp is earlier than any earlier posts, we could backdate all previous posts || reorder the posts
  3. If new timestamp is later than any following posts, we could reorder the posts || update the timestamp of all the subsequent posts

Does that mean we should reorder based on the timestamp?

Now that I am writing it out, that are many scenarios that we have to consider :worried:

@Abdul_Munim_Zahid What was the reason you had to change the timestamp of a posts on your end? I’m trying to understand the use case here better :smiley_cat:

(Kane York) #18

Don’t ever update the timestamp of following posts, but consider it for preceding posts that are before the new time.

(Sam Saffron) #19

no don’t even think about doing this. this is such an edge case, I would simply disallow creation of out-of-chronology times and avoid all this crazy.

Post #1 (1 day ago)
Post #2 (1 hour ago)

  • Changing Post #1 to 2 days ago is allowed
  • Changing Post #1 to 1 minute ago is not allowed
  • Changing Post #2 to 2 days ago is not allowed

Simplest approach for a feature 0.0001 of Discourse admins will ever use.

Only look at non-deleted posts in the stream, cause I guess for some draft stuff you may need to delete things and then change time.

(Jeff Atwood) #20

I agree with all that, but I see what @tgxworld is getting at. If, for some reason, I wanted to make a topic be from a week ago, I need to:

  • set the date on the last post in the topic
  • set the date on the 2nd to last post in the topic
  • set the date on the 3rd to last post in the topic

etc, etc, etc ad nauseam walking backwards up all the replies in the topic, until I get to the first post.

Still, we can defer that work until we need to deal with it.

(Sam Saffron) #21

Also keep in mind, there are 5 dates at play that are relevant.

post: updated_at, created_at
topic: updated_at, created_at, bumped_at

bumped_at is particularly difficult to deal with, I would ensure you just go ahead and set all 5 to the same thing if mucking with the OP

I would always ensure bumped_at is a non “impossible” state if you edit the last post on a topic.

(Alan Tan) #22

Right now I’m pretty confused. For single select, the bound of the new timestamp is limited to the timestamps of its immediate neighbour posts. For multiple select, we’re going to be opening up a can of worms. :frowning:

Do need actually need/want the feature? :smiley_cat:

(Sam Saffron) #23

Jeff wants it :slight_smile: but there are about 100 things that are more important than this :blush:

(Alan Tan) #24

No sunk costs for me here since working on the PR helped me to improve my EmberFu. Just wanted to make sure that we are serving an actual use case here because changing timestamps sound like it can potentially mess up a whole bunch of stuff.