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

Fix "Sort by: Published Date" #185

Open
3 of 11 tasks
Tracked by #134
KatharineV opened this issue Mar 14, 2024 · 18 comments
Open
3 of 11 tasks
Tracked by #134

Fix "Sort by: Published Date" #185

KatharineV opened this issue Mar 14, 2024 · 18 comments
Assignees
Labels
bug something isn't working Knapsack Upgrade M3 Milestone 3 reindex

Comments

@KatharineV
Copy link
Collaborator

KatharineV commented Mar 14, 2024

Summary

The "Sort by Published Date" (both ascending and descending) feature in the catalog search and in collections does not properly sort based on the "Publication date" metadata field. If this feature is sorting based on a different date field, perhaps that would explain the problem, but if so, then we still would request work on this ticket, as explained in the last paragraph.

If the feature is meant to sort based on the "Publication date" metadata field, then we'd like the functionality to work when dates are entered in that field according to the system's requirements. In this example collection on ADL staging, we used the UI to enter publication date metadata, so we assume the system entered the date in a format that it prefers to read. The back end gave us a calendar widget, which we used. The dates appear properly in each work's metadata. However, when we use the sort by published date feature in the collection, the works do not sort in date order. See screenshots below.

Acceptance Criteria

Catalog search

Image

Collection show pg (admin view)

Image

Screenshots or Video

Proper date in work metadata:
https://adl.s2.adventistdigitallibrary.org/concern/published_works/22255888_the_minnesota_worker_december_21_1898?locale=en

Image

Automatic relevant sorting in the collection:

Image

Sort By: Published Date (Ascending):

Image

Sort By: Published Date (Descending):

Image

These examples clearly show that the dates (which also appear in the work titles) are not sorting in proper order. They don't even change between ascending and descending. The behavior is the same in the catalog search, which offers a publication date sort.

If the feature is actually pulling from a different date field, we'd like to know which one is being referenced, what date format the system will recognize and use to sort properly, and we'd like the Sort By label to be renamed to match the metadata field being referenced.

As a sidenote only tangentially related to this ticket (and perhaps headed for its own ticket someday, or could be rolled into general Hyku upgrades of the future), the Publication Date metadata field seems like a bad choice for the catalog and collection search sort by feature. Not all works even have this metadata field in their work type. For example, Images. The sort by date feature would be better if it pulled a metadata field that appears in all work types, and it would be nice if there was a note in the UI that mentions to users that this is the field for date sorting. With soooooo many date fields across work types, it's very confusing what is used for search facets and sort by features etc. Additionally, the UI could contain a note regarding what date formats the system will actually recognize and use to sort. Is this info already included in Hyku documentation?
See this screenshot of the back end of the UI "add new work" for the kind of note I'm suggesting would include format info and info about sort and facet dependency. Hope this makes sense.

Image

Testing Instructions

Testing note: the staging site was partially reindexed resulting in most existing records being updated but not all. Our assumption is that the cut over will handle the update of all works in production. Most records will pass QA.

Ensure that works & collections have "Created Date" filled in. If there is no Created Date, they will sort to the end of the list, whether sorting by ascending or descending.

  • Go to the catalog index page
  • Use the drop down menu to sort by the following
    • Title
    • Author
    • Published date (asc)
    • Published date (desc)
  • Go to the Dashboard > Collection > select a collection with associated works > scroll down to works index page
  • Use the drop down menu to sort by the following
    • Title
    • Author
    • Published date (asc)
    • Published date (desc)

Notes

This will require an update of data to remove ["0~"] from blank author (creator) fields.

@christhepianist
Copy link

christhepianist commented Mar 14, 2024 via email

@jillpe
Copy link

jillpe commented Apr 4, 2024

This was done in pals for a different date (date created)

notch8/palni-palci#867

@KatharineV
Copy link
Collaborator Author

Folks, the Sort By feature isn't working at all on a collection right now. When I created this ticket, we didn't have Knapsack. We are post Knapsack now, so I can't be sure if the cut over is responsible for the lack of functionality or if I overlooked and failed to test the other sort by options. Maybe it was always broken.

Here's the collection where I'm having trouble:
https://adl.b2.adventistdigitallibrary.org/collections/b1cb4449-c0ee-4499-82da-32c1246daeea

Automatic relevance sort (which isn't sorted by any metric that I can determine):

Image

I select "Sort By: Upload Date (Descending)" and hit Refresh and this is what I get:

Image

I select "Sort By: Title" and hit Refresh and this is what I get:

Image

@kirkkwang kirkkwang transferred this issue from notch8/adventist-dl May 10, 2024
@jillpe jillpe moved this to Ready for Development in Adventist Knapsack May 10, 2024
@jillpe jillpe removed the status in Adventist Knapsack May 10, 2024
@jillpe jillpe added the bug something isn't working label May 10, 2024
@jillpe jillpe moved this to Ready for Development in Adventist Knapsack May 15, 2024
@orangewolf
Copy link
Contributor

Sorting does work (you have to hit refresh after making change) but sort by title is backward and sort by dates could not be verified easily. Need to look at those

@ShanaLMoore ShanaLMoore added the M3 Milestone 3 label Sep 3, 2024
@jillpe
Copy link

jillpe commented Sep 4, 2024

This was fixed in UTK

@sjproctor sjproctor self-assigned this Sep 6, 2024
@sjproctor sjproctor moved this to In Development in adventist-dl Sep 6, 2024
@sjproctor sjproctor moved this to In Development in Adventist Knapsack Sep 6, 2024
sjproctor added a commit to samvera/hyku that referenced this issue Sep 9, 2024
This commit fixes a bug in the ability to sort works by "Published
date", "Upload date", and "Title" in the catalog search page and the
collection show page.

Ref:
- notch8/adventist_knapsack#185
sjproctor added a commit to samvera/hyku that referenced this issue Sep 9, 2024
This commit fixes a bug in the ability to sort works by "Published
date", "Upload date", and "Title" on the catalog search page and the
collection show page.

Ref:
- notch8/adventist_knapsack#185
sjproctor added a commit to samvera/hyku that referenced this issue Sep 9, 2024
This commit adds a guard clause to the `SortTitle` model to fix failing
tests due to a nil value being assigned to `@title` on initialization.

Ref:
- notch8/adventist_knapsack#185
@sjproctor
Copy link
Contributor

We identified the source of the sorting problem is coming from Hyku. We are making the changes there first.

https://github.com/samvera/hyku/pull/2316/files

sjproctor added a commit that referenced this issue Sep 17, 2024
This commit pulls in an update to Hyku that fixes a bug when sorting by
title, author, and created date (published date). The Hyku indexing
moves from `CollectionResource` to `CollectionResourceIndexer`.

Ref:
- #185
@sjproctor sjproctor moved this from In Development to Code Review in adventist-dl Sep 17, 2024
@sjproctor sjproctor moved this from In Development to Code Review in Adventist Knapsack Sep 17, 2024
sjproctor added a commit to samvera/hyku that referenced this issue Sep 18, 2024
This commit moves the HykuIndexing module from the CollectionResource to
the CollectionResourceIndexer.

Ref:
- notch8/adventist_knapsack#185
@sjproctor
Copy link
Contributor

  • If a record does not have a author (creator) the field will have ["0~"] due to an older version of the order_already gem.
  • The newest version of the gem handles this issue. The gem version was updated in Hyku and in the submodule of this application.
  • However, existing records in ADL with ["0~"] will not register the author (creator) field as blank and therefore do not display or sort properly.
  • To fix this problem, all records with ["0~"] in the creator field need to be updated. This can be done with the following script:
concerns = Hyrax.config.curation_concerns.map{ |c| "#{c}Resource".safe_constantize } << CollectionResource

concerns.each do |concern|
  works = Hyrax.query_service.find_all_of_model(model: concern)
  works.each do |work|
    next unless work['creator'] == ["0~"]
    work.creator = []
    work.save
  end
end

sjproctor added a commit that referenced this issue Sep 23, 2024
# Story

The "Sort by Published Date" (both ascending and descending) feature in
the catalog search and in collections does not properly sort based on
the "Publication date" metadata field.

Ref:
- #185

# Expected Behavior Before Changes

Title, author, and publication date sort fields did not sort properly on
the catalog search results page or the collection show page.

# Expected Behavior After Changes

The user is able to sort by title, author, and publication date on the
catalog search results page as well as the collection show page.

# Screenshots / Video


https://github.com/user-attachments/assets/23ca2643-f0f4-498f-91b3-2ccc2b5e9714

# Notes

This updated required an update of the submodule as well as reindexing
local works and collections.
@sjproctor sjproctor moved this from Code Review to Deploy to Staging in adventist-dl Sep 23, 2024
@sjproctor sjproctor moved this from Code Review to Deploy to Staging in Adventist Knapsack Sep 23, 2024
@sjproctor sjproctor moved this from Deploy to Staging to SoftServ QA in adventist-dl Sep 25, 2024
@sjproctor sjproctor moved this from Deploy to Staging to SoftServ QA in Adventist Knapsack Sep 25, 2024
@ShanaLMoore
Copy link

ShanaLMoore commented Sep 25, 2024

QA Results: ❌ NEEDS REWORK

TLDR: sort by published date doesn't appear to be working for Collections. Kirk ran a staging reindex yesterday and in the tested example, I manually edit/saved each work to be sure it's not an indexing problem.

tested on STAGING

Testing note: the staging site was partially reindexed resulting in most existing records being updated but not all. Our assumption is that the cut over will handle the update of all works in production. Most records will pass QA.

CATALOG INDEX PAGE ✅

  • Go to the catalog index page
  • Use the drop down menu to sort by the following
    • Title
    • Author
    • Published date (asc)
    • Published date (desc)

Image

COLLECTION PAGE ❌

tested on STAGING

  • Go to the Dashboard > Collection > select a collection with associated works > scroll down to works index page
  • Use the drop down menu to sort by the following
    • Title
    • Author
    • Published date (asc) ❌
    • Published date (desc) ❌

Image

@ShanaLMoore ShanaLMoore assigned laritakr and unassigned sjproctor Sep 25, 2024
@ShanaLMoore ShanaLMoore moved this from SoftServ QA to In Development in adventist-dl Sep 25, 2024
@ShanaLMoore ShanaLMoore moved this from In Development to Ready for Development in adventist-dl Sep 25, 2024
@ShanaLMoore ShanaLMoore added the needs rework issue needs additional work label Sep 25, 2024
@KatharineV
Copy link
Collaborator Author

Team, as you're fixing this ticket, can you also educate me on which date field is used for the Sort By Published Date feature? There are so many date fields and they vary between work types. I have never been clear on which field maps to this feature, so your insight will be valuable.

@ShanaLMoore
Copy link

cc @sjproctor could you provide some insight here? ^^

@sjproctor
Copy link
Contributor

sjproctor commented Sep 26, 2024

Yeah, there are definitely a lot of date fields! We are using the date_created_ssi for publication date.

@laritakr
Copy link
Contributor

laritakr commented Sep 26, 2024

This shows as "Date Created" on the work's metadata.

The input form uses a calendar entry that puts a date into mm/dd/yyyy format, but via bulkrax, I am seeing dates such as yyyy-mm-dd. Without a consistent format, we can't do a clean sort.

@KatharineV
Copy link
Collaborator Author

@laritakr Thank you! These are the instructions I needed. I've tried to find out before which field and which format the system prefers. The answer wasn't available when I asked the last couple times, so this is really great. I understand why the sort won't work unless we make revisions. We can default to mm/dd/yyyy, but (in case the community ever sits down to think about this) I would love to see modifications in future versions that allow for ISO standard dates, since mm/dd/yyyy is confusing across international boundaries.

Well, forget that for now, and thank you again!

@laritakr
Copy link
Contributor

laritakr commented Sep 26, 2024

@laritakr Thank you! These are the instructions I needed. I've tried to find out before which field and which format the system prefers. The answer wasn't available when I asked the last couple times, so this is really great.

You're welcome! Glad I could add clarity. Based on what I have found, I am moving this ticket back to QA.

As an added note, I found that anything with no created date will sort at the end, whether using ascending OR descending.

We could put in some date standardization as we index the date used for sorting. This would require a reindex of all works & collections. If this is a desired change, you would need to make a ticket for it.

@laritakr laritakr removed the needs rework issue needs additional work label Sep 26, 2024
@laritakr laritakr moved this from Ready for Development to Client QA in adventist-dl Sep 26, 2024
@laritakr laritakr moved this from Client QA to SoftServ QA in adventist-dl Sep 26, 2024
@laritakr
Copy link
Contributor

laritakr commented Sep 26, 2024

QA Results: ✅ Passed

(previously passed catalog view QA)

COLLECTION PAGE ✅

tested on STAGING

Created Dates were added to several works - I added the dates into the title so the results are obvious.

  • Go to the Dashboard > Collection > select a collection with associated works > scroll down to works index page
  • Use the drop down menu to sort by the following
    • Title
    • Author
    • Published date (asc)
    • Published date (desc)

Screenshot 2024-09-26 at 2 10 30 PM

Screenshot 2024-09-26 at 2 10 43 PM

@laritakr laritakr moved this from SoftServ QA to Client QA in adventist-dl Sep 26, 2024
@KatharineV
Copy link
Collaborator Author

Folks, does the date_created field also inform the date range facet on the catalog search page?
image

@laritakr
Copy link
Contributor

Folks, does the date_created field also inform the date range facet on the catalog search page?

Yes, date_created is also used to build the sorted date. It expects the date_created to be in the format yyyy-mm-dd to extract the year to be used for sorting.

@KatharineV
Copy link
Collaborator Author

I tested this ticket with a set of works (see importer) deposited into a single collection. I put date metadata into the date_created column of the CSV. The final version metadata CSV is attached to that importer. When I formatted dates as 5/1/2023, 5/2/2023, 5/3/2023 and so on, the sort by date feature did NOT work. However, when I entered just the year, the sort worked and put works in the expected order. So, the feature works as described earlier in this ticket.

I tested the sort on the collection dashboard page, the public show page, and in the catalog search.

@jillpe jillpe moved this from Client QA to Deploy to Production in adventist-dl Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working Knapsack Upgrade M3 Milestone 3 reindex
Projects
Status: Deploy to Production
Status: Deploy to Production
Development

No branches or pull requests

7 participants