Web-stories-wp: Dashboard Stories on created_by sort should be alphabetical

Created on 12 May 2020  路  18Comments  路  Source: google/web-stories-wp

Bug Description

In the dashboard (https://stories-new-wordpress-amp.pantheonsite.io/wp-admin/edit.php?post_type=web-story&page=stories-dashboard#/) when you sort stories by 'author' the current user's stories come first regardless of true alphabetization.

Expected Behaviour

This isn't so much a bug as updated specs. Now the story sort by author should just be a straight a - z (descending) or z -a (ascending).

API for reference: orderby=story_author
wp/v2/web-story?context=edit&order=asc&orderby=story_author&page=1&per_page=10&status=publish%2Cdraft&_locale=user

Steps to Reproduce

Go to dashboard, sort stories by author.

Reference PRs:

- https://github.com/google/web-stories-wp/pull/1737#issuecomment-627393762

_Do not alter or remove anything below. The following sections will be managed by moderators only._

Acceptance Criteria

QA Instructions

  1. Verify that sorting stories on the dashboard by the author works, and that they're ordered by the displayed author name in the correct way (ascending and descending)
Dashboard WordPress P1 PHP WP & Infra Passed

All 18 comments

@BrittanyIRL I imagine this is an open ask on the WP team? If so, can we fix the pod label? Just let me know and I can update it. :)

Also, to capture here, this is my video of an issue I saw with sorting which may be related

Can we also make sure that the sort is applied to the full result set (e.g., all stories) not just those in the paginated view? If I sort by author a-z, I should see all stories from an author called Anna before getting to Ben, regardless of pagination/loaded results.

Right now, when you sort stories by 'author' the current user's stories come first regardless of true alphabetization.

This issue sounds like we need to get rid of that behavior and just do simple sorting as expected.

That means two things:

  1. dashboard pod needs to change sorting param (one line change probably)
  2. WP pod needs to remove all the magic code that we used for this.

Please correct me if I鈥榤 wrong

@swissspidy So we are sending story_author as the orderby and asc or desc as order. We can adjust that to whatever we need to be!

For default alphabetical ordering of authors you could pass just author instead.

@swissspidy Does the author param automatically sort by alphabetically? My guess would be that is sort by the author id desc as it using the post_author. To sort by the the author name, would have to do a left join and order a field in the wp_users table.

@spacedmonkey Ah, dang, you are right 馃う Sounds like we have to that join then.

@swissspidy If we do a left join, what field should we sort by? There are 3 fields that I think may map here. display_name, user_nicename or user_login. I am thinking display_name. But this field is not indexed as I remember.

Whatever field that is used for displaying on the stories dashboard. Display name I think?

And yes, no indexes available :-(

For author we get the users and then match up the id and then display name. users[story.author]?.name

@spacedmonkey could you take that on?

asc/desc toggle isn't refreshing display when in Dashboard List view:
image.png

I think this is actually on the API side of things. When I look at the responses for the respective sorts they are the same, when they should be ordered differently.

https://stories-new-wordpress-amp.pantheonsite.io/wp-json/wp/v2/web-story?context=edit&order=asc&orderby=story_author&page=1&per_page=20&status=publish%2Cdraft&_locale=user

https://stories-new-wordpress-amp.pantheonsite.io/wp-json/wp/v2/web-story?context=edit&order=desc&orderby=story_author&page=1&per_page=20&status=publish%2Cdraft&_locale=user

(where order= )

returning to @spacedmonkey for input

@BrittanyIRL You are testing on stories-new-wordpress-amp.pantheonsite.io, but the PR with this fix (#2345) has not been merged yet (merge happens _after_ QA).

If you wanna test the fix, try the stories-qa-wordpress-amp.pantheonsite.io site and switch to the PR there, or check out the PR locally.

Sorting appears to be working just fine locally:

Screen Recording 2020-06-17 at 14.21.59.mov.zip

@csossi could you perhaps share a video of your test? also on the QA environment, of course.

odd - can't seem to replicate - "pass"ing this one

Merging PR now, so it should be live on stories-new-wordpress-amp.pantheonsite.io momentarily.

Verified in UAT however @BrittanyIRL

  1. I'm on the ALL tab
  2. Sort by author
  3. Then scroll down the list
  4. Then click on Drafts or Published, the list should start at the top. Currently, it's starting at the same scroll position. @jauyong is there already a bug filed for this?

I don't think there's an issue for this. Let's create one 馃憤 Is there a spec for this? First time I'm hearing of this requirement.

Opened #2596.

Was this page helpful?
0 / 5 - 0 ratings