Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine chronological display of published notes that were previously saved as drafts #9985

Closed
ebarry opened this issue Aug 3, 2021 · 10 comments · Fixed by #9989 or #9995
Closed

Refine chronological display of published notes that were previously saved as drafts #9985

ebarry opened this issue Aug 3, 2021 · 10 comments · Fixed by #9989 or #9995
Labels
feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute

Comments

@ebarry
Copy link
Member

ebarry commented Aug 3, 2021

Please describe the desired behavior.

Returning to a comment from @jywarren from #2667 (comment) that was not taken up at that time. It's about updating the date when publishing posts that were drafted, and saved as drafts, on an earlier date:

Second, we set a final url with the publish date in it. I wonder if we should reset the url at the moment of final publication, and before then we can use a temporary one, resetting this on publication? This is a little complex but seems workable, no? There's a generate_path method to recalculate the path with the current title and date. That way the title could be changed as well and this would reflect in the final URL.

This would be very helpful as currently if someone publishes a draft even from a week ago, there's too much newer activity for it to even show up on the first page of latest results.

cc @steviepubliclab

@ebarry ebarry added the feature explains that the issue is to add a new feature label Aug 3, 2021
@jywarren
Copy link
Member

jywarren commented Aug 3, 2021

Thanks!

We actually did forward-date the post, but maybe some pages sort by revision timestamp instead of node timestamp?

def publish_draft
@node = Node.find(params[:id])
if current_user && current_user.uid == @node.uid || current_user.can_moderate? || @node.has_tag("with:#{current_user.username}")
@node.path = @node.generate_path
@node.slug = @node.slug.split('token').first
@node['created'] = DateTime.now.to_i # odd assignment needed due to legacy Drupal column types
@node['changed'] = DateTime.now.to_i
@node.publish

If so, we should be able to add a couple more lines there. Do you think this is worth writing a test against, or should we just make the additions and see if it works upon publishing?

@jywarren
Copy link
Member

jywarren commented Aug 3, 2021

I think we'd just do this, just after line 419:

     @node.latest['timestamp'] = DateTime.now.to_i # odd assignment needed due to legacy Drupal column types 
     @node.save

@jywarren jywarren added fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute labels Aug 3, 2021
@jywarren
Copy link
Member

jywarren commented Aug 3, 2021

Also, can you double check whether a recently published draft URL matches the publication date/time? According to the quoted code above, we are setting the URL correctly, just not the revision timestamp. But it's possible we have that wrong too, do you have an example of a published draft we can examine to confirm? Thanks!

@ebarry
Copy link
Member Author

ebarry commented Aug 3, 2021

How about examining this case?

there was a community member who posted this on Feb 13, 2020 : https://publiclab.org/notes/WendyBrawer/08-20-2019/how-to-get-street-trees-for-your-community however it's showed up as an older post a few pages back in the activity feed because she's been drafting it since august 2019.

@jywarren
Copy link
Member

jywarren commented Aug 3, 2021

Thanks, that's very helpful. OK, so we have a few places where sorting happens:

  1. on the old (current) dashboard, we sort by id which is a problem because we can't change the unique id. However, with the new dashboard this wouldn't be an issue.
  2. at https://publiclab.org/research, which will preserve the dashboard-style "firehose", we also use this display-by-unique-id form. I think we could change this but maybe it's not an issue, @ebarry what do you think?
  3. on tag pages, we sort by revision timestamp, as we theorized above, so that should be an easy fix.
  4. on the new dashboard, we use topic cards (template code here) and these are sorted by node.created for notes, and revision.timestamp for other types (wikis), which would be fixed by the above proposed solution.

So with the exception of (2) above, this simple fix should solve it, and if you are OK not fixing this on the older dashboard.

Is the https://publiclab.org/research page going to be used enough that we should try to solve it there too?

@jywarren
Copy link
Member

jywarren commented Aug 3, 2021

The minimal fix is now in testing at #9989

@ebarry ebarry changed the title Upon publishing draft note, use generate_path method to recalculate the path with the current title and date Refine display of published notes that were previously saved as drafts Aug 3, 2021
@ebarry ebarry changed the title Refine display of published notes that were previously saved as drafts Refine chronological display of published notes that were previously saved as drafts Aug 3, 2021
@ebarry
Copy link
Member Author

ebarry commented Aug 3, 2021

ah great detective work! Yes, i believe the staff are going to be looking at the firehose view to make sure we're not missing anything, so let's also fix this for /research please. Thank you for sorting this out.

@jywarren
Copy link
Member

jywarren commented Aug 3, 2021

#9989 was merged, and if you can test it out on stable that would be great. Fixing it on firehose view is a bit more involved, I'll look into it in the coming week. Thanks!

@jywarren jywarren reopened this Aug 3, 2021
@jywarren jywarren removed the fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet label Aug 3, 2021
@jywarren
Copy link
Member

jywarren commented Aug 3, 2021

I think this could involve changing this line to sort by revision.timestamp instead:

def activity
blog = Tag.find_nodes_by_type('blog', 'note', 1).first
# remove "classroom" postings; also switch to an EXCEPT operator in sql, see https://github.com/publiclab/plots2/issues/375
hidden_nids = Node.hidden_response_node_ids
notes = Node.where(type: 'note')
.where('node.nid NOT IN (?)', hidden_nids + [0]) # in case hidden_nids is empty
.order('nid DESC')

But i'm not sure what the ramifications are of that change. It could just work. Or it could cause unexpected issues. I think the best way forward is to just try it out in a pull request.

@TildaDares would you have any interest in trying this change out? It'd intended to help sort draft notes by their final publication date, rather than their unique id. If not, no worries!

@TildaDares
Copy link
Member

@jywarren I’ll take a look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute
Projects
None yet
3 participants